QueryResult<T> class Null safety

A 2-state result represents synchronised query with single return value It could be either succeeded or failed

Typically wrapped in a future as the return value of an action execution.

Future<QueryResult<User>> findUser(String userId);

QueryResult.succeeded creates the SucceededResult, indicates the query is succeded with a value QueryResult.failed creates the FailedResult, indicates the query is failed

See also

Implemented types

Constructors

QueryResult(T value)
Alias to QueryResult.succeeded
const
factory
QueryResult.failed(dynamic error, [StackTrace? stackTrace])
creates the FailedResult error is the Error/Exception fails the action stackTrace indicates where the error was thrown, it is optional
const
factory
QueryResult.from(StatedResult result)
Create QueryResult from any other result
factory
QueryResult.succeeded(T value)
Creates the SucceededResult with value
const
factory

Properties

hashCode int
The hash code for this object.
read-onlyinherited
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
read-onlyinherited
isFailed bool
Return ture when the query/action has finished with error
read-onlyinherited
isFinished bool
Return true when query/action has been finished either with or without error
read-onlyinherited
isNotStarted bool
Return true when query/action hasn't been started
read-onlyinherited
isSucceeded bool
Return true when query/action has finished successfully, regardless it is an action or query
read-onlyinherited
isWaiting bool
Return true when query/action is being processed
read-onlyinherited
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

Methods

asFailed() FailedResult
inherited
asValueResult<T>() ValueResult<T>
inherited
map<TR>({required ValueResultMapper<T, TR> succeeded, required FailedResultMapper<TR> failed}) → TR
Pattern match the result
mapValue<TR>(ValueMapper<T, TR> mapper) QueryResult<TR>
map the value of query. If it is a SucceededResult, map its value with mapper. Otherwise, keep the result.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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