RequestController<T> class
Manages the state and lifecycle of an asynchronous request.
This controller handles the data, loading, and error states, as well as provides methods to run, refresh, and cancel the request.
Constructors
-
RequestController.new(Future<
T> service(), RequestOptions<T> options)
Properties
-
data
→ Ref<
T?> -
The fetched data. It is a Ref so you can watch it for changes.
final
-
error
→ Ref<
Object?> -
The error object if the request fails. It is a Ref.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
loading
→ Ref<
bool> -
The loading state of the request. It is a Ref.
final
-
options
→ RequestOptions<
T> -
The options for the request.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
service
→ Future<
T> Function() -
The asynchronous function that fetches the data.
final
Methods
-
cancel(
) → void - Cancels the request.
-
dispose(
) → void - Cleans up the controller.
-
mutate(
T newValue) → void - Manually updates the local data.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
refresh(
) → Future< void> - Re-runs the request. Alias for run.
-
run(
) → Future< void> - Executes the request.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited