Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit cd65337

Browse files
committed
Complete Picture.toImage futures with an exception if the image is null
See #24877 Fixes flutter/flutter#78429
1 parent 994b854 commit cd65337

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/ui/painting.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4879,13 +4879,17 @@ class Picture extends NativeFieldWrapperClass2 {
48794879
if (width <= 0 || height <= 0)
48804880
throw Exception('Invalid image dimensions.');
48814881
return _futurize(
4882-
(_Callback<Image> callback) => _toImage(width, height, (_Image image) {
4883-
callback(Image._(image));
4882+
(_Callback<Image?> callback) => _toImage(width, height, (_Image? image) {
4883+
if (image == null) {
4884+
callback(null);
4885+
} else {
4886+
callback(Image._(image));
4887+
}
48844888
}),
48854889
);
48864890
}
48874891

4888-
String? _toImage(int width, int height, _Callback<_Image> callback) native 'Picture_toImage';
4892+
String? _toImage(int width, int height, _Callback<_Image?> callback) native 'Picture_toImage';
48894893

48904894
/// Release the resources used by this object. The object is no longer usable
48914895
/// after this method is called.

0 commit comments

Comments
 (0)