Skip to content

julienandco/validated_text_field

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages