WellFormed.app constructor

WellFormed.app(
  1. List<Widget> fields, {
  2. bool enabled = true,
  3. bool hasReset = true,
  4. String title = '',
  5. Widget submitChild = const Text('Submit'),
  6. Widget resetChild = const Text('Reset'),
  7. Widget? leading,
  8. VoidCallback? onSub,
  9. VoidCallback? onReset,
  10. ButtonStyle? submitStyle,
  11. ButtonStyle? resetStyle,
  12. Axis scrollDirection = Axis.vertical,
  13. GlobalKey<FormState>? formKey,
  14. Key? submitKey,
  15. Key? resetKey,
  16. Key? key,
})

A Form within a MaterialApp container.

This configuration is suitable for unit testing or when the whole application boils down to the form itself.

fields the Form's fields. enabled enable/disable flag. hasReset if true, the form will have a reset button. title the MaterialApp.title value. 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, a new key 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.app(
  List<Widget> fields, {
  bool enabled = true,
  bool hasReset = true,
  String title = '',
  Widget submitChild = const Text('Submit'),
  Widget resetChild = const Text('Reset'),
  Widget? leading,
  VoidCallback? onSub,
  VoidCallback? onReset,
  ButtonStyle? submitStyle,
  ButtonStyle? resetStyle,
  Axis scrollDirection = Axis.vertical,
  GlobalKey<FormState>? formKey,
  Key? submitKey,
  Key? resetKey,
  Key? key,
})  : _toForm = ((context) {
        return MaterialApp(
          title: title,
          debugShowCheckedModeBanner: false,
          home: Scaffold(
            body: WellFormed.btn(
              fields,
              enabled: enabled,
              hasReset: hasReset,
              formKey: formKey,
              submitChild: submitChild,
              resetChild: resetChild,
              leading: leading,
              submitStyle: submitStyle,
              resetStyle: resetStyle,
              scrollDirection: scrollDirection,
              onSub: onSub,
              onReset: onReset,
              resetKey: resetKey,
              submitKey: submitKey,
            ),
          ),
        );
      }),
      super(key: key);