Predefined Flutter widgets
GladeForms comes with set of predefined widget to help you build your forms.
GladeModelProvider
Provides your GladeModel to the widget tree. Uses provider approach under the hood.
GladeModelProvider(
create: (context) => MyModel(),
child: MyForm(),
);
GladeFormBuilder
Use GladeFormBuilder to create a form with your model. It provides a builder function that gives you access to the model and rebuilds when the model changes.
GladeFormBuilder<MyModel>(
builder: (context, model, child) {
return Column(
children: [
TextFormField(
initialValue: model.name,
onChanged: (value) => model.name = value,
),
ElevatedButton(
onPressed: () {
if (model.validate()) {
// Submit the form
}
},
child: Text('Submit'),
),
],
);
},
);