https://github.com/kennethnym/former_gen
Code generation for former.
https://github.com/kennethnym/former_gen
Last synced: 2 months ago
JSON representation
Code generation for former.
- Host: GitHub
- URL: https://github.com/kennethnym/former_gen
- Owner: kennethnym
- License: mit
- Created: 2021-05-04T00:18:59.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-08-29T15:19:42.000Z (over 3 years ago)
- Last Synced: 2025-01-20T06:45:33.577Z (4 months ago)
- Language: Dart
- Size: 17.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# former_gen
Code generation for former.
## Usage
0. Make sure `build_runner` is installed.
1. Annotate your form class with `@Formable`
2. Add `part '.g.dart';` before your class declaration
3. Add `class YourForm = _YourForm with _$YourFormIndexable;`
4. Run `flutter pub get build_runner build`
5. A `.g.dart` file should be generated next to the file that contains your form class.## What's generated
- A mixin that makes your form class "indexable" with the bracket operator.
- An enum class that includes all the fields of your form.
They are used when you need to specify what field a particular
Former widget should control.
- A schema class that you should create when using the `Former` widget.
Use it to describe the requirements of your form, using either the built-in validators
or create your own by implementing `Validator` class.