Skip to content

Form

A behavioral boundary that coordinates descendant FormField widgets.

Learn more: Forms & validation

Import: package:fleury/fleury.dart, or package:fleury/fleury_core.dart in browser code.

Form(
controller: form,
onSubmit: saveProject,
child: Column(children: [
FormField(
validator: () => name.text.isEmpty ? 'Enter a name.' : null,
child: TextInput(controller: name),
),
Button(text: 'Save', onPressed: form.submit),
]),
)

Form owns no values and imposes no panel, wizard, or field layout. Values stay in ordinary application state and validators close over that state.

Creates a behavioral form boundary around child.

ParameterTypeDefaultDescription
controller:FormController?—Optional externally-owned command surface. More
semanticLabel:String?—Accessible name for this form when the surrounding heading is not enough.
onSubmit:FutureOr<void> Function()requiredCalled after every mounted, enabled field validates successfully. More
child:WidgetrequiredThe application-defined form layout.
  • controller: When omitted, Form creates one that descendants can read with of.
  • onSubmit: An error it throws or returns goes to whoever submitted: a caller that awaits FormController.submit receives it. One that doesn’t, such as a button or the form’s semantic submit action, leaves it uncaught, and runApp reports it and keeps the app running.

Form is defined in packages/fleury/lib/src/catalog/form.dart.

Category: Forms · All widgets