reactive_forms
18.2.2, released 11 months ago by an unverified publisher
Model-driven form handling and validation inspired by Angular Reactive Forms
What it does
Separates form data models and validation logic from UI widgets using FormGroups, FormArrays, and FormControls. It provides built-in sync and async validators, custom validation hooks, and specialized widgets that bind directly to reactive controls. It tracks validity, touched status, and enabled states across nested form structures.
AI-written summary of version 18.2.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- Building complex forms with inter-dependent field validations like password matching
- Managing dynamic form structures like arrays or groups of inputs that grow at runtime
- Needing fine-grained control over validation timing, asynchronous checks, or error message display
Skip it when
- The application only requires a few basic text inputs where standard Flutter Form and TextFormField suffice
- You prefer pure immutable functional form modeling without Angular-style control objects
Strengths
- Rich set of pre-built validators, cross-field validation, and async validator support with debounce
- Comprehensive suite of dedicated reactive widgets (text fields, checkboxes, pickers)
- Clean separation of form state and business logic from the widget tree
Weaknesses
- Steep learning curve if not already familiar with Angular's reactive form concepts
- Requires high minimum Flutter SDK version (>=3.29.0) for the latest release
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
May require intl dependency override if version conflicts occur.
final form = FormGroup({
'name': FormControl<String>(value: 'John Doe', validators: [Validators.required]),
'email': FormControl<String>(validators: [Validators.required, Validators.email]),
});
// Access form data
print(form.value);Alternatives
Packages that do the same job and could replace reactive_forms.
Works with
Packages commonly used together with reactive_forms: ones it builds on, ones built on it, and its own family.
- intlreactive_forms depends on itA Dart library for internationalization and localization, providing message translation, plural/gender handling, and date/number formatting.
- reactive_forms_annotationsBuilt on reactive_formsAnnotations for reactive_forms_generator to generate form models
- reactive_date_time_pickerBuilt on reactive_formsA wrapper around Flutter date and time pickers to integrate them with reactive_forms.
- reactive_dropdown_searchBuilt on reactive_formsA wrapper around dropdown_search to use with reactive_forms.
- reactive_phone_form_fieldBuilt on reactive_formsReactive wrapper for phone_form_field to use with reactive_forms.
- reactive_image_pickerBuilt on reactive_formsProvides Reactive Forms compatible widgets for picking images and videos.