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.
ResultFutureOrUnwrap on FutureOr<Result<T, E>>
Provides call functionality to FutureOr values that complete with a Result type value.
ResultFutureUnwrap on Future<Result<T, E>>
Provides call functionality to Future values that complete with a Result type value.
ResultTranspose on Result<Option<T>, E>
Provides the transpose() method to Result type values that hold an Option value.

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.

Typedefs

FutureOrResult<T, E> = FutureOr<Result<T, E>>
Represents a FutureOr that is or completes with a Result of the given types T, E.
FutureResult<T, E> = Future<Result<T, E>>
Represents a Future that completes with a Result of the given types T, E.

Exceptions / Errors

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