Skip to content

Drop-in replacement for TextFormField with debounced validation

License

Notifications You must be signed in to change notification settings

itsJoKr/debounced_text_form_field

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

debounced_field_title

Drop in replacement for TextFormField that debounces the validation.

Motivation

While there are other debouncing packages available, this one builds on foundation of Form and validation provided by Flutter.

Just replace your TextFormField with DebouncedTextFormField and you are good to go. No extra widgets or builders needed.

DebouncedTextFormField(
  decoration: const InputDecoration(
    hintText: 'Enter email',
    prefixIcon: Icon(Icons.mail),
  ),
  validator: (value) => _mustBeValidEmail(value),
),

You can change debounce duration. Default is 1s as that's a good balance since you want to give user time to finish typing.

DebouncedTextFormField(
  debounceDuration: Duration(milliseconds: 500),
),

Special case:

  • The validation is run immediately when the field has correct value or when it's empty. This is to provide immediate feedback to the user that his input is valid.
  • There is no autovalidateMode parameter from TextFormField, as debouncing is a form of auto-validation.

Maintained by: [email protected]

debounced_field_footer

About

Drop-in replacement for TextFormField with debounced validation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published