ResultOf<T> class

Generic version of Result that holds value

Inheritance

Constructors

ResultOf({required bool isSuccess, required T? value, List<ResultError> error = const []})

Properties

error ResultError?
no setterinherited
errorMessage String
The reason why operation has been failed
no setterinherited
errors List<ResultError>
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
isFail bool
Returns whether the Result is fail
no setterinherited
isSuccess bool
Returns whether the Result is success
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → T?
Value of result
final

Methods

add(Object reason) → void
Add another error
inherited
addAll(List<Object> errors) → void
Add other errors
inherited
contains<T extends ResultError>() bool
Contains the Result a error or not
inherited
fold({required dynamic onFail(List<ResultError> errors), required dynamic onSuccess()}) → void
Fold the result
inherited
foldWithValue({required dynamic onFail(List<ResultError> errors), required dynamic onSuccess(T value)}) → void
Fold the result
get<T extends ResultError>() → T?
try get the specific error
inherited
map<U>([U valueConverter(T)?]) ResultOf<U?>
Convert result with value to result with another value. Use valueConverter parameter to specify the value transformation logic.

No need valueConverter for Fail result. But for Success you should define it.

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

failWith<T>(dynamic reason) ResultOf<T?>
Result with fail reason
success<T>(T data) ResultOf<T>
Create success Result with value
tryAsync<T>(Future<ResultOf<T>> func(), {ResultOf<T?> onError(dynamic e)?, void onFinally()?}) Future<ResultOf<T?>>
Wrapped on try/catch
override
trySync<T>(ResultOf<T> func(), {ResultOf<T?> onError(dynamic e)?, void onFinally()?}) ResultOf<T?>
Wrapped on try/catch