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.
ResultTildeUnwrap on Result<T, E>
Provides the ~ operator for unwrapping Result type values.
ResultTranspose on Result<Option<T>, E>
Provides the transpose() method to Result type values that hold an Option value.
ResultUnitUnwrap on Result<(), E>
Provides the ~ operator to Result type values that hold () to provide an ergonomic way to unwrap Result type values used strictly for error handling.

Functions

catchResult<T, E>(Result<T, E> fn()) Result<T, E>
Executes the given function, returning the returned Result value.
catchResultAsync<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.