From cda084e0a3feb4f96e2c8750ca207f12f816c1cd Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Thu, 18 Mar 2021 10:56:01 -0700 Subject: [PATCH] Complete Picture.toImage futures with an exception if the image is null (flutter/engine#25058) --- engine/src/flutter/lib/ui/painting.dart | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/lib/ui/painting.dart b/engine/src/flutter/lib/ui/painting.dart index 1ea33ebb90c..fad462dd738 100644 --- a/engine/src/flutter/lib/ui/painting.dart +++ b/engine/src/flutter/lib/ui/painting.dart @@ -4879,13 +4879,17 @@ class Picture extends NativeFieldWrapperClass2 { if (width <= 0 || height <= 0) throw Exception('Invalid image dimensions.'); return _futurize( - (_Callback callback) => _toImage(width, height, (_Image image) { - callback(Image._(image)); + (_Callback callback) => _toImage(width, height, (_Image? image) { + if (image == null) { + callback(null); + } else { + callback(Image._(image)); + } }), ); } - String? _toImage(int width, int height, _Callback<_Image> callback) native 'Picture_toImage'; + String? _toImage(int width, int height, _Callback<_Image?> callback) native 'Picture_toImage'; /// Release the resources used by this object. The object is no longer usable /// after this method is called.