From 061b66d3378cd6713cb25e0fcf770e4786c6545c Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Tue, 22 Dec 2020 10:17:46 -0800 Subject: [PATCH] eturn valid type from Future.catchError. An upcoming feature to the Dart analyzer [0] will report Future.catchError [1] `onError` handlers which return values of invalid type. Currently this is not reported because the `onError` handler function type cannot be accurately expressed. An `onError` handler for `Future.catchError` must be either `FutureOr Function(dynamic)` or `FutureOr Function(dynamic, StackTrace)`. In either case, the return type of the function is `FutureOr`. This CL corrects `onError` handler(s) to return a value of a valid type. [0]: https://github.com/dart-lang/sdk/issues/35825 [1]: https://api.dart.dev/dev/2.12.0-149.0.dev/dart-async/Future/catchError.html --- lib/src/picture_provider.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/picture_provider.dart b/lib/src/picture_provider.dart index 3bb7a693..11a057d0 100644 --- a/lib/src/picture_provider.dart +++ b/lib/src/picture_provider.dart @@ -601,7 +601,7 @@ class FilePicture extends PictureProvider { key.toString(), ).catchError((Object error, StackTrace stack) async { onError(error, stack); - return null; + return Future.error(error, stack); }); } return decoder(data, colorFilter, key.toString());