form library

Headless typed forms, validation, submission and optional autosave.

Classes

FieldController<T, V>
FieldValidators<T, V>
FormAutosave<T>
Optional serialized autosave. A rejected revision is never automatically retried; a subsequent edit, explicit flush, or explicit retry is required.
FormController<T>
FormErrors
FormFieldKey<T, V>
Typed lens into an immutable draft. Paths are stable, including array indexes.
FormFieldMeta
FormIssue
A backend path and rule code survive localization and routing to a control.
FormNavigationGuard
Router-neutral guard registry. Apps call canLeave before route or dialog changes and install their browser unload/history adapter at the app shell.
FormOptions<T>
FormState<T>
FormSubmitContext<T>
FormSubmitResult<T>
Return invalid/uncertain rather than reporting a successful transport write.
FormValidationContext<T>
FormValidationSignal
FormValidators<T>

Functions

formValueEquals(Object? a, Object? b) → bool
Structural comparison for immutable collections; models may provide equals.
useField<T, V>(FormController<T> form, FormFieldKey<T, V> key, {FieldValidators<T, V> validators = const FieldValidators()}) → FieldController<T, V>
useForm<T>(FormOptions<T> options, {List<Object?> keys = const []}) → FormController<T>
Owns a draft for the component lifetime. New defaultValues do not replace edits on a rebuild; call reset explicitly after loading another record.
useFormAutosave<T>(FormController<T> form, {Duration debounce = const Duration(milliseconds: 600), bool canSave()?, Future<bool> save()?}) → FormAutosave<T>
useFormNavigationGuard(FormNavigationGuard guard, bool blocked()) → void
useFormState<T, S>(FormController<T> form, S selector(FormState<T>), {bool equals(S, S)?}) → S
Subscribe at the smallest component that renders the selected state.

Typedefs

AsyncFormValidator<T> = Future<FormErrors?> Function(FormValidationContext<T> context)
FormValidator<T> = FormErrors? Function(FormValidationContext<T> context)