fromFuture<R, S> static method
Future<Result<R, S> >
fromFuture<R, S>(
- Future<
R> future, { - required S error(
- dynamic e,
- StackTrace s
Create a Result from a Future.
If future
completes successfully then Result will contain its value,
and if the future
fails then its error will be contained in Result
Implementation
static Future<Result<R, S>> fromFuture<R, S>(
Future<R> future, {
required S Function(dynamic e, StackTrace s) error,
}) async {
try {
return Result<R, S>.ok(await future);
} catch (e, s) {
return Result<R, S>.err(error(e, s));
}
}