result library

This is the result library, containing only the Result type and its helpers.

This library can be imported via:

import 'package:option_result/result.dart';

If you want to import both Option and Result types, consider importing the combined library:

import 'package:option_result/option_result.dart';

Classes

Err<T, E>
A type that represents the failure Result of something.
Ok<T, E>
A type that represents the successful Result of something.
Result<T, E>
A type that represents the result of something, either success (Ok) or failure (Err).

Extensions

ResultFlatten on Result<Result<T, E>, E>
Provides the flatten() method to Result type values that hold another Result.
ResultPropagateShortcut on Result<T, E> Function()
Provides the ~ shortcut for functions that return Result to allow propagating unwrapped Err values up the call stack.
ResultPropagateShortcutAsync on Future<Result<T, E>> Function()
Provides the ~ shortcut for asynchronous functions that return Result to allow propagating unwrapped Err values up the call stack.
ResultTranspose on Result<Option<T>, E>
Provides the transpose() method to Result type values that hold an Option value.

Functions

propagateResult<T, E>(Result<T, E> fn()) Result<T, E>
Executes the given function, returning the returned Result value.
propagateResultAsync<T, E>(FutureOr<Result<T, E>> fn()) Future<Result<T, E>>
Executes the given function asynchronously, returning the returned Result value.

Exceptions / Errors

ResultError<T, E>
Represents an error thrown by a mishandled Result type value.