Result<R, S> class
Result class that can either contain a value on success, or an error on failure
- Annotations
-
- @immutable
Constructors
- Result.err(S error)
-
Create a Result with an
error
const - Result.ok([R? _value])
-
Create a result with a value
const
Properties
- error → S
-
Get the error from this Result. This will throw error if this Result
has a value instead. Check isError before accessing this.
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- isError → bool
-
Check if this Result contains an error
no setter
- isNotError → bool
-
Opposite of isError
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → R
-
Get the value from this Result. This will throw error if this Result
is an error. Check isError before accessing this.
no setter
Methods
-
flatMap<
U> (Result< U, S> f(R)) → Result<U, S> -
The flatMap function allows chaining of operations that return a Result.
If this Result is value, it applies
f
to the value inside. If this Result is error, it returns the error. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Methods
-
fromAsyncCallback<
R, S> (Future< R> future(), {required S error(dynamic e, StackTrace s)}) → Future<Result< R, S> > - Create a Result from a callback that returns a Future.
-
fromFuture<
R, S> (Future< R> future, {required S error(dynamic e, StackTrace s)}) → Future<Result< R, S> > - Create a Result from a Future.