A powerful Flutter package for automatically generating forms from data models with validation, customization, and theming support.
15,240
Downloads
128
Likes
95%
Popularity
NOCORPS
Author
formbuildervalidationuiwidget
# Auto Form Builder
A comprehensive Flutter package that automatically generates beautiful, functional forms from your data models with built-in validation, theming, and customization options.
## Features
✅ **Automatic Form Generation** - Generate forms from data classes
✅ **Built-in Validation** - Comprehensive validation with custom rules
✅ **Material Design 3** - Modern UI with full theming support
✅ **Accessibility** - Full screen reader and accessibility support
✅ **Internationalization** - Support for 15+ languages
✅ **Dark Theme** - Automatic dark theme support
✅ **Custom Widgets** - Easy custom field widget integration
## Quick Start
### Installation
Add this to your package's `pubspec.yaml` file:
```yaml
dependencies:
auto_form_builder: ^2.1.0
```
### Basic Usage
```dart
import 'package:auto_form_builder/auto_form_builder.dart';
class UserModel {
String name;
String email;
int age;
UserModel({required this.name, required this.email, required this.age});
}
class MyFormPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Auto Form Example')),
body: AutoFormBuilder<UserModel>(
model: UserModel(name: '', email: '', age: 0),
onSubmit: (model) {
print('Form submitted: ${model.name}, ${model.email}, ${model.age}');
},
validators: {
'email': [EmailValidator()],
'age': [RangeValidator(min: 18, max: 100)],
},
),
);
}
}
```
## Advanced Configuration
### Custom Themes
```dart
AutoFormBuilder<UserModel>(
model: UserModel(),
theme: AutoFormTheme(
primaryColor: Colors.blue,
fieldDecoration: InputDecoration(
border: OutlineInputBorder(),
filled: true,
fillColor: Colors.grey[100],
),
),
onSubmit: (model) => handleSubmit(model),
)
```
### Custom Validators
```dart
class CustomEmailValidator extends FieldValidator {
@override
String? validate(String? value) {
if (value == null || value.isEmpty) {
return 'Email is required';
}
if (!RegExp(r'^[^@]+@[^@]+.[^@]+').hasMatch(value)) {
return 'Please enter a valid email';
}
return null;
}
}
```
## Examples
Check out our comprehensive examples:
- [Basic Form Example](https://github.com/nocorps/auto_form_builder/tree/main/example/basic)
- [Advanced Validation](https://github.com/nocorps/auto_form_builder/tree/main/example/validation)
- [Custom Theming](https://github.com/nocorps/auto_form_builder/tree/main/example/theming)
- [Internationalization](https://github.com/nocorps/auto_form_builder/tree/main/example/i18n)
## Contributing
We welcome contributions! Please read our [Contributing Guidelines](CONTRIBUTING.md) before submitting PRs.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Installation
Add this package to your pubspec.yaml file:
# pubspec.yaml
dependencies:
auto_form_builder: ^2.1.0
Then run flutter pub get to install the package.