autoform 0.0.3 autoform: ^0.0.3 copied to clipboard
A simple package to help you build forms. A form builder with code controlled validation.
autoform #
A simple package to help you build forms.
Getting Started #
Straight forward form builder.
Simple implementation #
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
var form = AutoForm(
values: {'name': 'Edwards'},
properties: [
AutoProperty(
field: 'name',
title: 'Name',
validator: AutoValidators.isEmail,
type: AutoPropertyType.text,
),
AutoProperty(
field: 'personality',
title: 'Personality Type',
validator: AutoValidators.isEmail,
type: AutoPropertyType.multiselect,
options: ['Simple', 'Complex', 'Other']),
],
).create();
@override
void initState() {
super.initState();
var s = AutoFormSettings();
s.fieldMargin = EdgeInsets.symmetric(vertical: 20);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: Column(
children: [
form.widget,
ElevatedButton(
onPressed: () {
var isValid = form.form.validate();
if (isValid) {
print("Form validated");
} else {
print("Errors");
}
},
child: Text("Validate"),
),
],
),
),
);
}
}