Giter VIP home page Giter VIP logo

validated_text_field's Introduction

validated_text_field

A Flutter Widget that automatically validates its input and displays error messages given a FormzInput instance.

Features

  • Provides a ValidatedTextInputField Widget.

Getting started

Add the dependency to the package to your pubspec.yaml:

dependencies:
   validated_text_field:
    git:
      url: https://github.com/julienandco/validated_text_field
      ref: main

Usage

enum TestError {
  error1,
  error2,
  error3,
}

class TestData extends FormzInput<String, TestError> {
  TestData.pure() : super.pure('');
  TestData.dirty(super.value) : super.dirty();

  @override
  TestError? validator(String value) {
    if (value.contains('1')) return TestError.error1;
    if (value.contains('2')) return TestError.error2;
    if (value.contains('3')) return TestError.error3;
    return null;
  }
}

...
@override
Widet build(BuildContext context){
    return ValidatedTextField(
        initialInput: TestData.pure(),
        standardErrorText: 'unknown error',
        getErrorSpecificText: (error) => error.toString(),
        onChanged: (value) {
        print(value);
        },
    );
}

Additional information

Feel free to contact me if you have any questions, open some pull requests, or want to contribute to this package.

validated_text_field's People

Contributors

julienandco avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.