AsyncFormValue<Request, Response> class sealed

A class that represents the state of a form, inspired by AsyncValue from Riverpod.

This class can be in one of four states:

  • AsyncFormIdle: The form is in its initial state, not yet submitted.
  • AsyncFormData: The form has data, which may include initial values, request data, and response data.
  • AsyncFormError: An error occurred. It contains the error and stack trace, and can preserve previous data.
  • AsyncFormLoading: The form is in a loading state. It can preserve previous data while loading.
Implementers

Constructors

AsyncFormValue.data({required Request request, required Response response})
Creates a form state with data.
const
factory
AsyncFormValue.error(Object error, StackTrace stackTrace, {Request? request, Response? response})
Creates a form state for an error.
const
factory
AsyncFormValue.idle()
Creates an idle form state (initial state, not yet submitted).
const
factory
AsyncFormValue.loading({Request? request, Response? response})
Creates a loading form state.
const
factory

Properties

error Object?
no setter
hasError bool
Whether the form is in an error state.
no setter
hashCode int
The hash code for this object.
no setterinherited
hasValue bool
Whether the form has data.
no setter
isIdle bool
Whether the form is in its initial idle state.
no setter
isLoading bool
Whether the form is currently in a loading state.
no setter
request → Request?
no setter
response → Response?
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

map<R>({required R idle(AsyncFormIdle<Request, Response> idle), required R data(AsyncFormData<Request, Response> data), required R error(AsyncFormError<Request, Response> error), required R loading(AsyncFormLoading<Request, Response> loading)}) → R
Pattern-matching over the form state.
maybeMap<R>({R idle(AsyncFormIdle<Request, Response> idle)?, R data(AsyncFormData<Request, Response> data)?, R error(AsyncFormError<Request, Response> error)?, R loading(AsyncFormLoading<Request, Response> loading)?, required R orElse}) → R
Optional pattern-matching over the form state.
maybeWhen<R>({R? idle, R? data, R? error, R? loading, required R orElse}) → R
Optional pattern-matching over the form state with direct values.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
when<R>({required R idle, required R data, required R error, required R loading}) → R
Pattern-matching over the form state with direct values.

Operators

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