WellFormed.btn constructor
- List<
Widget> fields, { - bool enabled = true,
- bool hasReset = true,
- Widget submitChild = const Text('Submit'),
- Widget resetChild = const Text('Reset'),
- Widget? leading,
- ButtonStyle? submitStyle,
- ButtonStyle? resetStyle,
- VoidCallback? onSub,
- VoidCallback? onReset,
- Axis scrollDirection = Axis.vertical,
- GlobalKey<
FormState> ? formKey, - Key? submitKey,
- Key? resetKey,
- Key? key,
Convenient Scrollable Form Widget that contains a ElevatedButton for submission along with an optional reset TextButtonfor resetting all form fields back to their FormField.initialValue.
fields
the Form's fields.
enabled
enable/disable flag.
hasReset
if true, the form will have a reset button.
submitChild
the child widget of the submission button.
resetChild
the child widget of the reset button.
leading
if set, an extra widget will be placed on the leftmost position
alongside the submission and reset buttons.
scrollDirection
the axis along which the scroll view scrolls.
formKey
the form state key; if omitted, one will be generated.
submitKey
the submit button key — it might be useful for unit testing.
resetKey
the reset button key — it might be useful for unit testing.
Implementation
WellFormed.btn(
List<Widget> fields, {
bool enabled = true,
bool hasReset = true,
Widget submitChild = const Text('Submit'),
Widget resetChild = const Text('Reset'),
Widget? leading,
ButtonStyle? submitStyle,
ButtonStyle? resetStyle,
VoidCallback? onSub,
VoidCallback? onReset,
Axis scrollDirection = Axis.vertical,
GlobalKey<FormState>? formKey,
Key? submitKey,
Key? resetKey,
Key? key,
}) : this.scroll(
fields,
scrollDirection: scrollDirection,
submit: (VoidCallback submit) {
return ElevatedButton(
key: submitKey,
style: submitStyle,
onPressed: !enabled
? null
: () {
submit();
onSub?.call();
},
child: submitChild,
);
},
reset: (VoidCallback reset) {
return !hasReset
? const SizedBox()
: TextButton(
key: resetKey,
style: resetStyle,
onPressed: !enabled
? null
: () {
reset();
onReset?.call();
},
child: resetChild,
);
},
leading: leading,
formKey: formKey,
key: key,
);