Option<T>.tryCatch constructor
Option<T>.tryCatch (
- T f()
Try to run f
and return Some(a)
when no error are thrown, otherwise return None
.
Implementation
factory Option.tryCatch(T Function() f) {
try {
return Some(f());
} catch (_) {
return const Option.none();
}
}