AsyncQueryResult<T> class
abstract
A 4-state result represents asychronised query with single query value It could be either pending, waiting, succeeded, or failed
Typically used with Bloc
or ValueNotifier
AsyncQueryResult.pending creates the PendingResult, indicates the query hasn't started. AsyncQueryResult.waiting creates the WaitingResult, indicates the query is in progress AsyncQueryResult.succeeded creates the SucceededResult, indicates the query is succeded with a value AsyncQueryResult.failed creates the FailedResult, indicates the query is failed
Optionally, AsyncQueryResult.initialValue can be used to create InitialValueResult, indicates the query hasn't started, but a default value is given.
See also
- Implemented types
Constructors
- AsyncQueryResult()
-
Alias to AsyncQueryResult.pending
factory
- AsyncQueryResult.failed(dynamic error, [StackTrace? stackTrace])
-
Creates the FailedResult, indicates the query is failed
constfactory
- AsyncQueryResult.from(StatedResult result)
-
Create AsyncQueryResult from any other result
factory
- AsyncQueryResult.fromValue(T? value)
-
Create the result from
value
. Ifvalue
isnull
, PendingResult is created Otherwise SucceededResult holdsvalue
is createdfactory - AsyncQueryResult.initialValue(T value)
-
Create InitialValueResult, indicates the query hasn't started but a default value is given.
constfactory
- AsyncQueryResult.pending()
-
Creates the PendingResult, indicates the query hasn't started
factory
- AsyncQueryResult.succeeded(T value)
-
Creates the SucceededResult, indicates the query is succeded with a value
constfactory
- AsyncQueryResult.waiting()
-
Creates the WaitingResult, indicates the query is in progress
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasValue → bool
-
Return true when query resut has a value, either it is intial value or the result after running query
It also indicates whether state implemented the ValueResult contract, regardless the type of the value
no setterinherited
- isFailed → bool
-
Return ture when the query/action has finished with error
no setterinherited
- isFinished → bool
-
Return true when query/action has been finished either with or without error
no setterinherited
- isNotStarted → bool
-
Return true when query/action hasn't been started
no setterinherited
- isSucceeded → bool
-
Return true when query/action has finished successfully, regardless it is an action or query
no setterinherited
- isWaiting → bool
-
Return true when query/action is being processed
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
asFailed(
) → FailedResult -
inherited
-
asValueResult<
T> () → ValueResult< T> -
inherited
-
map<
TR> ({required ResultMapper< TR> pending, ValueResultMapper<T, TR> ? initialValue, required ResultMapper<TR> waiting, required ValueResultMapper<T, TR> succeeded, required FailedResultMapper<TR> failed}) → TR - Pattern match the result on all branches
-
mapOr<
TR> ({ResultMapper< TR> ? pending, ValueResultMapper<T, TR> ? initialValue, ResultMapper<TR> ? waiting, ValueResultMapper<T, TR> ? succeeded, FailedResultMapper<TR> ? failed, ResultMapper<TR> ? notStarted, ResultMapper<TR> ? finished, ValueResultMapper<T, TR> ? hasValue, required ResultMapper<TR> orElse}) → TR - Pattern match the result with else branch
-
mapValue<
TR> (ValueMapper< T, TR> mapper) → AsyncQueryResult<TR> -
map the value of query.
If it is a SucceededResult or InitialValueResult, map its value with
mapper
. Otherwise, keep the result. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
updateWith<
TR> (Future< QueryResult< future) → Stream<TR> >AsyncQueryResult< TR> > - Update self with future QueryResult
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited