async icon indicating copy to clipboard operation
async copied to clipboard

Use onError over catchError

Open natebosch opened this issue 4 years ago • 0 comments

Future.catchError is more error prone in null safe dart than onError because return type of the Function callback is not statically enforced and null was a common default value which no longer works.

Migrate all calls from catchError to onError to demonstrate best practices. The other usages in this package are mostly on Future<dynamic> and mostly look safe, though I can't rule out a type error in unusual situations.

There was at least one mistake made in the migration of this library - the code to ignore errors when completing a CancelableOperation as an error after it was already canceled would instead cause a type error to surface. Fix this and add a test.

natebosch avatar Mar 03 '21 00:03 natebosch