ResultOf<T> class

Generic version of Result that holds value

Inheritance

Constructors

ResultOf({required bool isSuccess, required T? value, ResultError? error})

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(ResultError error) → void
Add another error
inherited
addAll(List<ResultError> 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
get<T extends ResultError>() → T?
try get the specific error
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toResult<U>({U valueConverter(T)?}) ResultOf<U?>
Convert result with value to result with another value. Use valueConverter parameter to specify the value transformation logic.
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

fail<T>(ResultError? error) ResultOf<T?>
Create fail Result with reason of fail
success<T>(T data) ResultOf<T>
Create success Result with value
withError<T>(ResultError error) ResultOf<T?>
Create fail Result with reason of fail
withErrorMessage<T>(String message) ResultOf<T?>
withException<T>(Exception exception) ResultOf<T?>