Skip to content

FormField

One validated value in a Form.

Learn more: Forms & validation

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

FormField(
validator: () => slug.text.isEmpty ? 'Enter a slug.' : null,
child: TextInput(controller: slug, semanticLabel: 'Slug'),
)

The ordinary constructor discovers exactly one first-party value control inside child, so no binding argument or specialized wrapper is needed. Use FormField.builder for a custom or multi-control value.

Creates a field that automatically integrates one aware control in child.

ParameterTypeDefaultDescription
child:WidgetrequiredSubtree containing the field’s one automatically integrated control.
validator:String? Function()?—Returns the current error by reading application-owned state. More
error:String?—Controlled external error, typically returned by a server.
enabled:booltrueWhether the field takes part in validation. A disabled field is skipped when the form validates, shows no error, and is never focused as the first invalid field.
showErrorMessage:booltrueWhether the field renders its current error below the control.
errorBuilder:Widget Function(BuildContext context, String error)?—Optional replacement for the default styled error text.
  • validator: Keep validators free of side effects: revealed validation can refresh after forms, fields, or registered controls rebuild, including dependent fields.

Creates a field whose custom control is built from its live state.

Use this for one logical value represented by a custom or multi-control widget. The builder must call FormFieldState.valueChanged when its app-owned value changes.

ParameterTypeDefaultDescription
builder:Widget Function(BuildContext context, FormFieldState field)requiredCustom-control builder used by FormField.builder.
validator:String? Function()?—Returns the current error by reading application-owned state. More
error:String?—Controlled external error, typically returned by a server.
enabled:booltrueWhether the field takes part in validation. A disabled field is skipped when the form validates, shows no error, and is never focused as the first invalid field.
focusNode:FocusNode?—Optional external focus destination for FormField.builder. Otherwise attach FormFieldState.focusNode inside the builder.
showErrorMessage:booltrueWhether the field renders its current error below the control.
errorBuilder:Widget Function(BuildContext context, String error)?—Optional replacement for the default styled error text.

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

Category: Forms · All widgets