ready_form 0.0.5 ready_form: ^0.0.5 copied to clipboard
Package that help to manage forms
ReadyForm #
widget that wrap flutter form to simplify working with it
Features #
[x] Validate children [x] Scroll to first invalid item if validation failed [x] Ability to add reveal effect [x] ProgressButton that work smoothly with it
usage #
return ReadyForm(
onPostData: () async {
/// submit your data
},
child: ListView(
children: [
TextFormField(),
TextFormField(),
TextFormField(),
TextFormField(),
ProgressButton(child: Text(TR.of(context).login)),
],
),
);
- as you can see when you press the progress button the form will be submitted after check validations
so what if you need to submit your form by your self or you don't want to use the ProgressButton
#
then you have to use
ReadyFormKey
final ReadyFormKey formKey=ReadyFormKey();
Widget build(BuildContext context) {
return ReadyForm(
onPostData: () async {
/// submit your data
},
child: ListView(
children: [
TextFormField(),
TextFormField(),
TextFormField(),
TextFormField(),
ElevatedButton(
onPressed:(){
formKey.onSubmit();
},
child: Text(TR.of(context).login),
),
],
),
);
}
you can also use
ReadyForm.of(context)
usage #
return ReadyForm(
onPostData: () async {
/// submit your data
},
child: ListView(
children: [
TextFormField(),
TextFormField(),
TextFormField(),
TextFormField(),
Builder(builder: (context) {
// the context of the builder can now access the parent form
return ElevatedButton(
onPressed: () {
ReadyForm.of(context)!.onSubmit();
},
child: Text(TR.of(context).login),
);
}),
],
),
);