formz
0.8.1, released 3 months ago by verygood.ventures
A unified form representation and validation library for Dart.
What it does
Formz simplifies form handling and validation in a generic way by providing `FormzInput` classes to model individual fields and `FormzMixin` to aggregate them. It allows tracking purity, validity, and error states of form inputs explicitly.
AI-written summary of version 0.8.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want a robust, type-safe approach to form validation in Dart or Flutter.
- You are using BLoC or another state management library and need structured form inputs.
- You need to validate multiple inputs together and track submission status.
Skip it when
- You want automatic UI form building via JSON or standard Flutter Form widgets without custom classes.
- You prefer built-in TextEditingController logic without abstracting inputs.
Strengths
- Type-safe representation of form fields and errors.
- Supports pure and dirty states for validation feedback control.
- Supports caching validation results for expensive checks.
Weaknesses
- Requires writing boilerplate classes for each form input type.
- Does not provide out-of-the-box UI widgets for rendering forms.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
Not documented
import 'package:formz/formz.dart';
enum NameInputError { empty }
class NameInput extends FormzInput<String, NameInputError> {
const NameInput.pure() : super.pure('');
const NameInput.dirty({String value = ''}) : super.dirty(value);
@override
NameInputError? validator(String value) {
return value.isEmpty ? NameInputError.empty : null;
}
}Alternatives
Packages that do the same job and could replace formz.
- acanthis
A type-safe and composable data validation library for Dart and Flutter.
75Compare - fform
Build forms with fields, validations, and state management in Flutter.
67Compare - form_validator
Simplest form validation library for Flutter's form field widgets.
50Compare - validators
String validation and sanitization library for Dart
50Compare