Ok<T> class

Represent success result. See isOk, val getters and unpack, for getting it's value. Ok has Result as superclass. Ok(123) is Result == true

Inheritance

Constructors

Ok(T? _val)

Properties

err Error?
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
isErr bool
no setterinherited
isOk bool
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
unwrap → T
Returns result.val if result is Ok. Throws contained result.err if result is Err.
no setterinherited
val → T?
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
ok<T2>(T2 f(T)) Result<T2>
If result is Err then returns this Err as is. If result is Ok then returns result of call f(result.val). Result of call f() must be a value of type T2.
inherited
okAsync<T2>(Future<T2> f(T)) Future<Result<T2>>
The same as ok(), but wrapped with Future<...>. If result is Err then returns this Err as is. If result is Ok then returns result of call f(result.val). Result of call f() must be a value of type T2.
inherited
onErr(dynamic f(Error)) Result<T>
Calls f(result.err) with side effect if this result is Err. Anyway returns this result as is.
inherited
onOk(dynamic f(T)) Result<T>
Calls f(result.val) with side effect if this result is Ok. Anyway returns this result as is.
inherited
onResult(dynamic f(Result<T>)) Result<T>
Calls f(this) with side effect and return this as is.
inherited
or(T? f()) Result<T>
If this result is Ok, then returns it as is. If this result is Err, then call result = f(). If result of call f() is null, then returns Err. If result of call f() is value , then return Ok(value). If call of f() throws exception, then returns Err.
inherited
orAsync(Future<T> f()) Future<Result<T>>
If this result is Ok, then returns it as is. If this result is Err, then call result = await f(). If result of call f() is null, then returns Err. If result of call f() is value, then return Ok(value). If call of f() throws exception, then returns Err.
inherited
pipe<T2>(dynamic f(T)) Result<T2>
If result is Err then returns this Err as is. If result is Ok then returns result of call f(result.val). If result of call f() is null - returns Err('function returned null'). If result of call f() is Result - returns it as is. If call of f() throws exception, then returns Err.
inherited
pipeAsync<T2>(Future f(T)) Future<Result<T2>>
If result is Err then returns this Err as is. If result is Ok then returns result of call await f(result.val). If result of call f() is null - returns Err('function returned null'). If result of call f() is Result - returns it as is. If call of f() throws exception, then returns Err.
inherited
replacePossibleError(Error oldErrorReplacer(Error oldErr)) Result<T>
If the Result is a Err, then replaces internal err with result if given function oldErrorReplacer. Function oldErrorReplacer should take old error and return new error; And returns changed result; If the Result is a Ok, then return unchanged Result as is;
inherited
replacePossibleErrorWith(Error newErr) Result<T>
If the Result is a Err, then replaces internal err with newErr value. And returns changed result; If the Result is a Ok, then return unchanged Result as is;
inherited
test(bool testFunction(Result<T>), String failedTestMsg) Result<T>
Test this result and return Ok or Err.
inherited
toString() String
A string representation of this object.
inherited
unwrapOrDefault(T default_value) → T
Returns val if result is Ok. Returns default_value if result is Err.
inherited
unwrapOrElse(T elseFunc(Error? e)) → T
Returns result.val if result is Ok. Returns call of elseFunc(result.err) if result is Err.
inherited

Operators

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