TaskOption<R>.tryCatch constructor
TaskOption<R>.tryCatch (
- Future<
R> run()
Converts a Future that may throw to a Future that never throws but returns a Option instead.
Used to handle asynchronous computations that may throw using Option.
Implementation
factory TaskOption.tryCatch(Future<R> Function() run) =>
TaskOption<R>(() async {
try {
return Option.of(await run());
} catch (_) {
return const Option.none();
}
});