FormzInput<T, E> class
abstract
A FormzInput represents the value of a single form input field. It contains information about the value as well as validity.
FormzInput should be extended to define custom FormzInput instances.
enum FirstNameError { empty }
class FirstName extends FormzInput<String, FirstNameError> {
const FirstName.pure({String value = ''}) : super.pure(value);
const FirstName.dirty({String value = ''}) : super.dirty(value);
@override
FirstNameError? validator(String value) {
return value.isEmpty ? FirstNameError.empty : null;
}
}
- Implementers
- Annotations
Constructors
- FormzInput.dirty(T value)
-
Constructor which create a
dirty
FormzInput with a given value.const - FormzInput.pure(T value)
-
Constructor which create a
pure
FormzInput with a given value.const
Properties
- displayError → E?
-
The error to display if the FormzInput value
is not valid and has been modified.
no setter
- error → E?
-
Returns a validation error if the FormzInput is invalid.
Returns
null
if the FormzInput is valid.no setter - hashCode → int
-
The hash code for this object.
no setteroverride
- isNotValid → bool
-
Whether the FormzInput value is not valid.
A value is invalid when the overridden
validator
returns an error (non-null value).no setter - isPure → bool
-
If the FormzInput is pure (has been touched/modified).
Typically when the
FormzInput
is initially created, it is created using theFormzInput.pure
constructor to signify that the user has not modified it.final - isValid → bool
-
Whether the FormzInput value is valid according to the
overridden
validator
.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → T
-
The value of the given FormzInput.
For example, if you have a
FormzInput
forFirstName
, the value could be 'Joe'.final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
-
validator(
T value) → E? -
A function that must return a validation error if the provided
value
is invalid andnull
otherwise.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override