Result<Success, Failure> class

A simple Result wrapper.

You can declare Success and Failure Types as Generic Type..

Constructors

Result.failure(Failure failure)
Marks this Result as failing
factory
Result.success(Success value)
Marks this Result as successful.
factory

Properties

failure → Failure
returns the failure or null if the state is success.
read-only
isFailure → bool
returns true, if the result is in failure state.
read-only
isSuccess → bool
returns true, if the result is in success state.
read-only
success → Success
returns the success value or null if there is a failure.
read-only
hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

map<ResultType>(ResultType mapper(Success)) Result<ResultType, Failure>
Use map to convert a Result from one value type to another. Changes only value type, not the Failure.
when<ResultType>({ResultType success(Success), ResultType failure(Failure) }) → ResultType
Somehow like a switch case statement. You can return a Value from the functions success and failure.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator. [...]
inherited