The only difference I see is that onError also gets the Stacktrace passed as a parameter. In which situations would you choose one other the other?
The only difference I see is that onError also gets the Stacktrace passed as a parameter. In which situations would you choose one other the other?
Future<T> onError<E extends Object>(FutureOr<T> Function(E, StackTrace) handleError, {bool Function(E)? test})
Future<T> catchError(Function onError, {bool Function(Object error)? test});
onError is effectively a more precisely typed version of catchError.
So, with onError you can catch specific error types and specify a correctly typed error handler function, rather than all types and just a Function with catchError.