Complete Picture.toImage futures with an exception if the image is null (flutter/engine#25058)

This commit is contained in:
Jason Simmons
2021-03-18 10:56:01 -07:00
committed by GitHub
parent 17e51505e7
commit cda084e0a3

View File

@@ -4879,13 +4879,17 @@ class Picture extends NativeFieldWrapperClass2 {
if (width <= 0 || height <= 0) if (width <= 0 || height <= 0)
throw Exception('Invalid image dimensions.'); throw Exception('Invalid image dimensions.');
return _futurize( return _futurize(
(_Callback<Image> callback) => _toImage(width, height, (_Image image) { (_Callback<Image?> callback) => _toImage(width, height, (_Image? image) {
callback(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 /// Release the resources used by this object. The object is no longer usable
/// after this method is called. /// after this method is called.