leancode_forms library

Classes

BooleanFieldCubit<E extends Object>
A specialization of FieldCubit for a bool value.
FieldBuilder<T, E extends Object>
Listens to the given field and rerenders the child using builder.
FieldCubit<T, E extends Object>
A single form field which can be validated. Stores the current value, error text, and whether autovalidate is on. T is the held value, E is the type of an error. E cannot be nullable to be able to unambiguously detect lack of errors.
FieldState<T, E extends Object>
The state of a FieldCubit.
FormGroupCubit
A parent of multiple FieldCubits. Manages group validation and tracks changes as well as cleans up needed resources.
FormGroupState
The state of a FormGroupCubit.
MultiSelectFieldCubit<V, E extends Object>
A specialization of FieldCubit for a multiple choice of V values.
SingleSelectFieldCubit<V, E extends Object>
A specialization of FieldCubit for a single choice of V value from List of options.
TextFieldCubit<E extends Object>
A specialization of FieldCubit for a String value.

Enums

FieldStatus
The status of a FieldCubit.

Extensions

ValidatorCombinators on Validator<T, E>
Extension methods for Validator allowing to combine them.

Functions

and<T, E extends Object>(Iterable<Validator<T, E>> validators, [E? sharedMessage]) Validator<T, E>
Each of the given validators has to accept input. If some accept, first error is returned or sharedMessage if provided.
atLeastLength<E extends Object>(int minLength, E message) Validator<String?, E>
Rejects strings shorter than minLength.
boundedNonNegativeInteger<E extends Object>(int upperBound, E message) Validator<String?, E>
Of the form >upperBound or num where num is between 0 and upperBound inclusive
conditionalValidator<T, E extends Object>(Validator<T, E> validator, bool enabledGetter()) Validator<T, E>
If enabledGetter returns true validator is ran. Otherwise this accepts all input.
dynamicValidator<T, E extends Object>(Validator<T, E>? validatorBuilder()) Validator<T, E>
Creates a new validator.
exactly<E extends Object>(String string, E message) Validator<String?, E>
Requires to be exactly the given string.
filled<E extends Object>(E message) Validator<String?, E>
Rejects null and empty strings (including whitespace only strings).
nonNegativeDecimal<E extends Object>(E message) Validator<String?, E>
Checks if the value is a decimal with a value above or equal to 0.
nonNegativeInteger<E extends Object>(E message) Validator<String?, E>
Checks if the value is a integer with a value above or equal to 0.
notEmpty<T, E extends Object>(E message) Validator<List<T>?, E>
Rejects null and empty lists
nothing<E extends Object>(E message) Validator<String?, E>
Matches empty strings
notLongerThan<E extends Object>(int maxLength, E message) Validator<String?, E>
Rejects strings longer than maxLength.
notNull<T, E extends Object>(E message) Validator<T?, E>
Rejects null
or<T, E extends Object>(Iterable<Validator<T, E>> validators, [E? sharedMessage]) Validator<T, E>
Only one of the given validators has to accept input. If none accept, first error is returned or sharedMessage if provided.
positiveDecimal<E extends Object>(E message) Validator<String?, E>
Checks if the value is a decimal with a value above 0.
positiveInteger<E extends Object>(E message) Validator<String?, E>
Checks if the value is a integer with a value above 0.

Typedefs

AsyncValidator<T, E extends Object> = Future<E?> Function(T)
An async validate function receiving the current value and returning an error code.
ErrorTranslator<E extends Object> = String Function(E)
Translates an error to a string.
Validator<T, E extends Object> = E? Function(T)
A validate function receiving the current value and returning an error code. If null is returned, the value is considered valid.