easy_auto_form 0.0.2+1 easy_auto_form: ^0.0.2+1 copied to clipboard
Auto generate form from json schema
A widget that generates a form based on a given entity.
The EasyAutoForm
widget is designed to work with any entity that is represented as a Map<String, dynamic>
.
This means that it can be used with a wide variety of data types, including but not limited to:
- User profiles
- Product listings
- Blog posts
- Contact information
- Survey responses
The
EasyAutoForm
widget will generate input fields for each key in the entity map, and will automatically determine the appropriate input type based on the value type.
Features #
- Supports a variety of entity types, including user profiles, product listings, blog posts, contact information, and survey responses.
- Includes options to ignore specific fields, override input decoration for different data types, and handle form submission and cancellation.
Getting started #
- Add the dependency to your
pubspec.yaml
file:
dependencies:
easy_auto_form: ^0.0.1
- Install it
You can install packages from the command line:
$ flutter pub get
- Import it
Now in your Dart code, you can use:
import 'package:easy_auto_form/easy_auto_form.dart';
Usage #
The EasyAutoForm
widget is designed to work with any entity that is represented as a Map<String, dynamic>
.
This means that it can be used with a wide variety of data types, including but not limited to:
- User profiles
- Product listings
- Blog posts
- Contact information
- Survey responses
The
EasyAutoForm
widget will generate input fields for each key in the entity map, and will automatically determine the appropriate input type based on the value type.
import 'package:easy_auto_form/easy_auto_form.dart';
class User {
String name;
String email;
String password;
User({this.name, this.email, this.password});
Map<String, dynamic> toMap() {
return {
'name': name,
'email': email,
'password': password,
};
}
}
final user = User(name: 'John Doe', email: 'john@gmail.com', password '123456');
EasyAutoForm(
entity: user.toMap(),
onSaved: (entity) {
// Do something with the entity
},
onCancel: () {
// Do something when the form is cancelled
},
);
Additional information #
Input types #
String
values will be rendered asTextFormField
s.bool
values will be rendered asCheckbox
es.int
anddouble
values will be rendered asTextFormField
s withkeyboardType
set toTextInputType.number
.DateTime
values will be rendered asDateTimeField
s.