FormInput<V, I, E extends ValidationError> class abstract

A FormInput represents the value of a single form input field. It contains information about the value as well as validity (result).

FormInput should be extended to define custom FormInput instances.

class AgeInput extends FormInput<int, String, ValidationError> {
  const AgeInput.pristine({String value = ''}) : super.pristine(value);
  const AgeInput.dirty({String value = ''}) : super.dirty(value);

  Either<ValidationError, int> validate(String value) =>
    Either.tryCatch(() => int.parse(value),
      (e, s) => ValidationError(name, '$name should be a number.'));
}
Implemented types
Implementers
Available Extensions
Annotations
  • @immutable

Constructors

FormInput.dirty(String id, I value)
Constructor which creates a dirty FormInput with a given value.
const
FormInput.pristine(String id, I value)
Constructor which creates a pristine FormInput with a given value.
const

Properties

hashCode int
The hash code for this object.
no setteroverride
isPristine bool
If the FormInput is in pristine state (hasn't been touched/modified). Typically when the FormInput is initially created, it is created using the FormInput.pristine constructor to signify that the user has not modified it.
final
name String
final
result → Either<E, V>
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → I
The value of the given FormInput.
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
validate(I value) → Either<E, V>
A pure function that validates the given value and returns the result as Either<E, V>, encoding either a corresponding model value or an error message.
inherited

Operators

operator ==(Object other) bool
The equality operator.
override