https://github.com/acmesoftwarellc/uniform
A form library for Flutter that handles form validation and state management gracefully, with unified form representation.
https://github.com/acmesoftwarellc/uniform
dart dartlang flutter form form-validation
Last synced: 8 months ago
JSON representation
A form library for Flutter that handles form validation and state management gracefully, with unified form representation.
- Host: GitHub
- URL: https://github.com/acmesoftwarellc/uniform
- Owner: AcmeSoftwareLLC
- License: bsd-3-clause
- Created: 2023-06-14T08:03:43.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-20T04:51:04.000Z (over 1 year ago)
- Last Synced: 2024-12-17T14:39:13.840Z (over 1 year ago)
- Topics: dart, dartlang, flutter, form, form-validation
- Language: Dart
- Homepage:
- Size: 402 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
A form library for Flutter that handles form validation and state management gracefully,
with unified form representation.
Uniform handles the repetitive and annoying stuffโkeeping track of values/errors/visited fields, orchestrating validation, and handling submission.
## Features
- ๐ชถ Lightweight & extensive.
- ๐ฎ Unified form representation using controllers.
- ๐ Easy and customizable form validation API.
- ๐ง Built-in support for form submission and state management.
- ๐ ๏ธ Builders for quickly creating form fields.
- ๐ Compatible with any state management solution or vanilla Flutter States.
- ๐ Supports for global and local validators.
## Getting started
See the [Installing](https://pub.dev/packages/uniform/install) section.
No extra configurations needed.
## Usage
Note: Detailed Usage documentation is coming soon.
For now, please refer to the [example](https://github.com/AcmeSoftwareLLC/uniform/tree/main/example) for more details.
```dart
final formController = FormController(
validators: {const InputFieldValidator.required()},
);
TextFieldController.create(formController, tag: 'email')
..setValidators({const EmailInputFieldValidator()});
FieldController.create(formController, tag: 'remember_me', autoValidate: true)
..setInitialValue(false)
..setValidators({const PasswordInputFieldValidator()});
InputForm(
controller: formController,
child: Column(
children: [
TextInputFieldBuilder(
tag: 'email',
builder: (_, controller, textController) {
return TextFormField(
controller: textController,
decoration: InputDecoration(
hintText: 'Email Address',
errorText: controller.error.message,
),
enabled: !controller.isSubmitted,
onChanged: controller.onChanged,
);
},
),
const SizedBox(height: 16),
InputFieldBuilder(
tag: 'remember_me',
builder: (context, controller, _) {
return CheckboxListTile(
title: const Text('Remember Me'),
value: controller.value,
controlAffinity: ListTileControlAffinity.leading,
enabled: !controller.isSubmitted,
onChanged: controller.onChanged,
);
},
),
const SizedBox(height: 40),
FilledButton(
onPressed: () {
if(formController.validate()){
print('Form Submitted!');
}
},
child: const Text('Submit'),
),
],
),
),
```