thenOr<R> method
FutureOr<R>
thenOr<R>(
- R after(
- T resolved
- R onError(
- Object error,
- StackTrace stackTrace
Implementation
FutureOr<R> thenOr<R>(R after(T resolved), {R onError(Object error, StackTrace stackTrace)?}) {
final self = this;
if (self is Future<T>) {
final withThen = self.then(after);
if (onError != null) {
return withThen.catchError(onError);
} else {
return withThen;
}
} else {
try {
// ignore: unnecessary_cast
final res = after(self as T);
return res;
} catch (e, stack) {
if (onError != null) {
return onError(e, stack);
} else {
rethrow;
}
}
}
}