Result<T, E> class
abstract
A monad that represents the result of an operation which may contain a value if successful, or an error otherwise.
Constructors
- Result()
- Creates a Result.
- Result.error(E error)
-
Creates a Result that represents failure.
factory
- Result.value(T value)
-
Creates a Result that represents success.
factory
Properties
- error → E
-
Returns the error of this Result. A ResultError is throw if this Result
does not contain an error.
no setter
- failure → bool
-
Returns
true
if this Result is not successful.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- successful → bool
-
Returns
true
if this Result is successful.no setter - value → T
-
Returns the value of this Result. A ResultError is throw if this Result
does not contain a value.
no setter
Methods
-
contains(
T value) → bool -
Returns
true
if this Result containsvalue
. -
containsError(
E error) → bool -
Returns
true
if this Result containserror
. -
ifFailure(
void error(E)) → void - Calls the given function if this Result contains an error.
-
ifSuccessful(
void value(T)) → void - Calls the given function if this Result contains a value.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
unwrap(
T defaultValue) → T -
Returns the value of this Result, or
defaultValue
if Result does not contain a value. -
unwrapError(
E defaultError) → E -
Returns the error of this Result, or
defaultError
if Result does not contain an error.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited