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
Tbetween 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
Tinside 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
includeTimeis 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 honoursenabledwith 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
itemswithout 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 withmessage. -
fieldEquals<
T> (XFormField< T> other, ValueGetter<String> message) → FormFieldValidator<T> -
Accepts a value equal to the value of
other; otherwise fails withmessage. -
fieldNotEquals<
T> (XFormField< T> other, ValueGetter<String> message) → FormFieldValidator<T> -
Accepts a value different from the value of
other; otherwise fails withmessage. -
gt<
T extends Comparable< (Object?> >T other, ValueGetter< String> message) → FormFieldValidator<T> -
Accepts a null value or one greater than
other; otherwise fails withmessage. -
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 withmessage. -
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
bywithmessage. -
lt<
T extends Comparable< (Object?> >T other, ValueGetter< String> message) → FormFieldValidator<T> -
Accepts a null value or one less than
other; otherwise fails withmessage. -
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 withmessage. -
matches(
RegExp match, ValueGetter< String> message) → FormFieldValidator<String> -
Accepts a text that has a match for
match, treating null as empty; otherwise fails withmessage. -
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
lengthcharacters, treating null as empty; otherwise fails withmessage. -
A builder of dropdown menu entries that shows the text
itemLabelof each item. -
A builder of dropdown items that shows the text
itemLabelof each item. -
minLen(
int length, ValueGetter< String> message) → FormFieldValidator<String> -
Accepts a text of at least
lengthcharacters, treating null as empty; otherwise fails withmessage. -
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 withmessage. -
oneOf<
T> (Set< T> values, ValueGetter<String> message) → FormFieldValidator<T> -
Accepts a value that is one of
values; otherwise fails withmessage. -
validateAll<
T> (Iterable< TFormFieldValidator< validators, {String joiner = '\n• '}) → TFormFieldValidator<T> >T> -
Runs all
validatorsand joins their errors, each prefixed byjoiner; null when all accept the value. -
validateFirst<
T> (Iterable< TFormFieldValidator< validators) → TFormFieldValidator<T> >T> -
Runs
validatorsin 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
fieldwhen another built field offieldshas the same value, withmessage. -
validateUniqueBy<
E, T> ({required XFormFieldStore fields, required XFormField< E> field, required KeyOf<T, E> keyOf, required ValueGetter<String> message}) → FormFieldValidator<T> -
Rejects
fieldwhen an earlier built field offieldshas the samekeyOfkey, withmessage.
Typedefs
- AddButtonBuilder = Widget Function(BuildContext context, VoidCallback? add, String addButtonText)
-
Builds the add button of a list field;
addis 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< errors)Object?> > - 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 thevaluesof the items before it. - ItemLabelBuilder = String Function(String fieldId, int index)
-
Builds the label of the tab of the field
fieldIdatindex. -
ListFormFieldBuilder<
E> = Widget Function(ProxyFormFieldState< List< state, XFormFieldStore fields, List<E> >E> values) -
Builds the list of a field from its
fieldsand their currentvalues. -
ListFormFieldItemBuilder<
E> = Widget Function(ProxyFormFieldState< List< state, XFormField<E> >E> field, List<E> values, int index) -
Builds the item at
indexof a list field:fieldis its handle andvaluesthe values of all items. -
ListFormFieldItemBuilderWithItems<
E> = Widget Function(ProxyFormFieldState< List< state, XFormField<E> >E> field, E initialValue, int index, List<E> items) -
Like ListFormFieldItemBuilder, with the
initialValueof the item and theitemsit may still choose from. - ListItemBuilder = Widget Function(BuildContext context, String fieldId, int index)
-
Builds the content of the row of the field
fieldIdatindex. - ListItemRowBuilder = Widget Function(BuildContext context, Widget row, Widget remove)
-
Builds a row of a list field around its
rowcontent and itsremovebutton. -
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;
removeis 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;onPressedis null when the field is disabled.