flutterx_forms library

Typed Flutter form fields with validators, a form controller and the text, number, date, file, list and drop widgets built on them.

Classes

CustomContentInputDecorator
An InputDecorator around any child: the child sits inside the border and over the content padding.
DoubleEditingController
A text controller whose data is an optional double, written with a comma as decimal separator.
DoubleField
A NumberField of optional doubles written with a comma; the parameters beyond the number ones are those of TextField.
EditingControllerInterface<T>
A TextEditingController whose text is the encoded form of a typed data value.
InputDecoratorLoader
An InputDecorator that shows a progress indicator in place of its content, while something loads.
IntEditingController
A text controller whose data is an optional integer; empty text and a lone minus sign are null.
IntField
A NumberField of optional integers; the parameters beyond the number ones are those of TextField.
NoFocusNode
A focus node that never takes focus, used where a field must not be focusable.
NumberField<T extends num>
A text field for numbers of type T between min and max, with optional arrows that step the value.
NumberFieldArrows
The up and down arrows at the end of a NumberField: a tap steps the value by step, a long press keeps stepping until the pointer is released.
NumberFormField<T extends num?>
A form field of a number whose value follows the controller of its text: typing changes the value, setting the value rewrites the text, and a reset restores the value of the first build.
NumberInputFormatter<T extends num>
A text input formatter that keeps the text of a number field a valid number of type T inside its range.
ProxyFormField<T>
A form field whose value is computed from an inner form of fields.
ProxyFormFieldState<T>
The state of a ProxyFormField: it owns the inner fields and recomputes its value when they change.
SingleSideInputBorder
An input border that draws a single line on one side of the decorator, inset by margin.
TextListEditingController
A text controller whose data is a list of items written as text and drawn as highlighted chips.
XBoolFormField
A form field of a boolean, shown as a checkbox or a switch inside an input decorator.
XDateTimeFormField
A form field of an optional DateTime, shown as read-only text and picked in a date picker, followed by a time picker when includeTime is set.
XDoubleFormField
A form field of an optional double: a DoubleField whose value, text and arrows follow its XFormField.
XDropdownButtonFormField<T>
A DropdownButtonFormField attached to an XFormField that lists items, re-validates on change and honours enabled with or without a decoration.
XDropdownMenuFormField<T>
A form field of a DropdownMenu that lists items; a value that is not among them is cleared.
XDropView
A drop target for files that shows child over it.
XFile
A CrossFile is a cross-platform, simplified File abstraction.
XFileFormField
A form field of an optional file, picked with the file dialog or dropped on the field.
XFilesFormField
A form field of a list of files, picked with the file dialog or dropped on the field.
XFormField<T>
The handle of a form field of value type T: the key to read its state, its focus node and its text controller.
XFormFieldStore
The inner fields of a ProxyFormField, created on demand by id and disposed when they leave the store.
XIntFormField
A form field of an optional integer: an IntField whose value, text and arrows follow its XFormField.
XListFormField<E>
A form field of a list of items in rows with a remove button, an add button and, when reorderable, drag handles.
XListFormFieldBuilder<E>
A form field of a list of items of type E, each one in its own inner field, laid out by builder.
XListFormFieldWidget
The rows of a list form field with their add, remove and reorder controls.
XListTabsFormField<E>
A form field of a list of items, each one in its own tab with a remove button, plus an add button.
XListTabsFormFieldWidget
The tabs of a list form field with their add and remove controls; the page of a tab is built by itemBuilder.
XSetFormField<E>
A form field of a list of distinct items, each one chosen among items without repeating the others.
XTextFormField
A TextFormField attached to an XFormField: it shares its text controller and focus node, re-validates while it shows an error and submits the form on the done action.
XTextListFormField
A form field of a list of words typed in one text field and drawn as chips.
XTimeFormField
A form field of an optional TimeOfDay, shown as read-only text and picked in a time picker.

Enums

DragOperation
The operation a drop target announces to the user dragging over it.
GeometrySide
A side of a rectangular area, in the reading direction of the text.

Mixins

FormController<T extends StatefulWidget>
Gives a State a Form with typed field handles: it creates, validates, resets, saves and submits the fields.

Extensions

FormFieldStateExt on FormFieldState<T>
Validates a FormFieldState again only when it is already showing an error.
FormFieldValidatorExt on TFormFieldValidator<T>
Adapts a TFormFieldValidator to the FormFieldValidator a Flutter form field expects.
XFileExt on XFile
Helpers to give an XFile a MIME type.
XFormFieldExt on XFormField<T>
Attaches a field to a FormController.

Functions

contains(Pattern other, ValueGetter<String> message) → FormFieldValidator<String>
Accepts a text that contains other, treating null as empty; otherwise fails with message.
fieldEquals<T>(XFormField<T> other, ValueGetter<String> message) → FormFieldValidator<T>
Accepts a value equal to the value of other; otherwise fails with message.
fieldNotEquals<T>(XFormField<T> other, ValueGetter<String> message) → FormFieldValidator<T>
Accepts a value different from the value of other; otherwise fails with message.
gt<T extends Comparable<Object?>>(T other, ValueGetter<String> message) → FormFieldValidator<T>
Accepts a null value or one greater than other; otherwise fails with message.
gte<T extends Comparable<Object?>>(T other, ValueGetter<String> message) → FormFieldValidator<T>
Accepts a null value or one greater than or equal to other; otherwise fails with message.
listNonEmpty<T>(ValueGetter<String> message) → FormFieldValidator<Iterable<T>>
Rejects a null or empty list with message.
listUnique<T>(ValueGetter<String> message) → FormFieldValidator<Iterable<T>>
Rejects a list that has equal items with message.
listUniqueBy<T>(Object by(T), ValueGetter<String> message) → FormFieldValidator<Iterable<T>>
Rejects a list in which two items have the same key by with message.
lt<T extends Comparable<Object?>>(T other, ValueGetter<String> message) → FormFieldValidator<T>
Accepts a null value or one less than other; otherwise fails with message.
lte<T extends Comparable<Object?>>(T other, ValueGetter<String> message) → FormFieldValidator<T>
Accepts a null value or one less than or equal to other; otherwise fails with message.
matches(RegExp match, ValueGetter<String> message) → FormFieldValidator<String>
Accepts a text that has a match for match, treating null as empty; otherwise fails with message.
matchesEmail(ValueGetter<String> message) → FormFieldValidator<String>
Accepts a text that looks like an email address; otherwise fails with message.
maxLen(int length, ValueGetter<String> message) → FormFieldValidator<String>
Accepts a text of at most length characters, treating null as empty; otherwise fails with message.
A builder of dropdown menu entries that shows the text itemLabel of each item.
A builder of dropdown items that shows the text itemLabel of each item.
minLen(int length, ValueGetter<String> message) → FormFieldValidator<String>
Accepts a text of at least length characters, treating null as empty; otherwise fails with message.
nonBlank(ValueGetter<String> message) → FormFieldValidator<String>
Rejects a null text, an empty one and one made only of whitespace with message.
nonEmpty(ValueGetter<String> message) → FormFieldValidator<String>
Rejects a null or empty text with message.
nonNull<T>(ValueGetter<String> message) → FormFieldValidator<T>
Rejects a null value with message.
notIn<T>(Set<T> values, ValueGetter<String> message) → FormFieldValidator<T>
Accepts a value that is none of values; otherwise fails with message.
oneOf<T>(Set<T> values, ValueGetter<String> message) → FormFieldValidator<T>
Accepts a value that is one of values; otherwise fails with message.
validateAll<T>(Iterable<TFormFieldValidator<T>> validators, {String joiner = '\n• '}) → TFormFieldValidator<T>
Runs all validators and joins their errors, each prefixed by joiner; null when all accept the value.
validateFirst<T>(Iterable<TFormFieldValidator<T>> validators) → TFormFieldValidator<T>
Runs validators in order and returns the first error, or null when all accept the value.
validateUnique<T>({required XFormFieldStore fields, required XFormField<T> field, required ValueGetter<String> message}) → FormFieldValidator<T>
Rejects field when another built field of fields has the same value, with message.
validateUniqueBy<E, T>({required XFormFieldStore fields, required XFormField<E> field, required KeyOf<T, E> keyOf, required ValueGetter<String> message}) → FormFieldValidator<T>
Rejects field when an earlier built field of fields has the same keyOf key, with message.

Typedefs

AddButtonBuilder = Widget Function(BuildContext context, VoidCallback? add, String addButtonText)
Builds the add button of a list field; add is null when the field is disabled.
ComputeFieldData<T> = T Function(Map<String, dynamic> fields)
Computes the value of a ProxyFormField from the values of its inner fields by id.
ComputeText<T> = String Function(T value)
Computes the text shown in a file field from its value.
ControllerFactory<T> = TextEditingController Function(T? initialValue)
Creates the text controller of a field from its initial value.
InitializeFields<T> = void Function(T value, XFormFieldStore fields)
Creates the inner fields of a ProxyFormField for its initial value.
InnerErrorTextBuilder = String Function(List<FormFieldState<Object?>> errors)
Builds the error text of a ProxyFormField from its invalid inner fields.
ItemInitialValue<E> = E Function(List<E> values, int index)
Computes the initial value of the item at index, given the values of the items before it.
ItemLabelBuilder = String Function(String fieldId, int index)
Builds the label of the tab of the field fieldId at index.
ListFormFieldBuilder<E> = Widget Function(ProxyFormFieldState<List<E>> state, XFormFieldStore fields, List<E> values)
Builds the list of a field from its fields and their current values.
ListFormFieldItemBuilder<E> = Widget Function(ProxyFormFieldState<List<E>> state, XFormField<E> field, List<E> values, int index)
Builds the item at index of a list field: field is its handle and values the values of all items.
ListFormFieldItemBuilderWithItems<E> = Widget Function(ProxyFormFieldState<List<E>> state, XFormField<E> field, E initialValue, int index, List<E> items)
Like ListFormFieldItemBuilder, with the initialValue of the item and the items it may still choose from.
ListItemBuilder = Widget Function(BuildContext context, String fieldId, int index)
Builds the content of the row of the field fieldId at index.
ListItemRowBuilder = Widget Function(BuildContext context, Widget row, Widget remove)
Builds a row of a list field around its row content and its remove button.
NumberFieldBuilder<T> = Widget Function({required EditingControllerInterface<T?> controller, required InputDecoration decoration, required FocusNode focusNode, required List<TextInputFormatter>? inputFormatters, required TextInputType keyboardType, required int maxLength, required ValueChanged<String> onChanged, required bool readOnly})
Builds the text field of a NumberField from the pieces the number field computed for it.
OnFileDrop = FutureOr<void> Function(Stream<XFile> files)
Called with the files accepted by a drop, as a stream that reads them one at a time.
OnMimeTypeNotMatch = bool Function(String name, String? mimeType, Set<String> mimeTypes)
Decides what to do with a file whose MIME type is not accepted.
RemoveButtonBuilder = Widget Function(BuildContext context, VoidCallback? remove)
Builds the remove button of a row; remove is null when the row cannot be removed.
TextDecode<T> = T Function(String text)
Parses the text of a text controller into a value.
TextEncode<T> = String Function(T value)
Converts a value to the text shown in a text controller.
TFormFieldValidator<T> = String? Function(T value)
A validator for a field whose value is never null: it receives the value and returns the error message, or null.
UploadButtonBuilder = Widget Function(BuildContext context, Widget icon, VoidCallback? onPressed, bool hasError)
Builds the upload button of a file field around icon; onPressed is null when the field is disabled.