tryOr<T> function
T?
tryOr<T>(
- T? defaultValue,
- T closure()
Returns the result of the given closure
, or default
if an Exception was raised.
Implementation
T? tryOr<T>(T? defaultValue, T Function() closure) {
try {
return closure();
} on Exception {
return defaultValue;
}
}