Skip to content

justinmc/easy_form_fields

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Easy Form Fields

It can be complicated and verbose to get Flutter's form setup to validate when you want it to. This library provides a few pre-built classes that make some common use cases very easy.

API

This library exports several variations on TextFormField that handle validation in various ways. All other parameters on TextFormField are passed through directly to the underlying TextFormField.

EasyTextFormFieldFocus

Validates when the field has been focused and on any change after that.

EasyTextFormFieldFocus(
  validator: (String value) => value.length > 5 ? null : 'Must be longer than 5',
),

EasyTextFormFieldUnfocus

Validates only when the field is unfocused.

EasyTextFormFieldUnfocus(
  validator: (String value) => value.length > 5 ? null : 'Must be longer than 5',
),

Others?

Have a use case that's different than any of the given classes? Please file an issue or open a pull request!

If you want to roll your own solution, it may also be useful to take a look at the source code of the closest class to what you want. Copy it into your project and make the necessary modifications.

Lastly, don't forget that the default behavior of a TextFormField in Flutter is to validate only on submit, so if that's the behavior you want, there is no need for this libarary!

Example

A complete example can be found in the example/ directory of this project. It shows a form using EasyTextFormFieldFocus widgets to provide a realistic set of features.

About

Simple, pre-built fields for form validation in Flutter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages