Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/ui/compositing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ class Scene extends NativeFieldWrapperClass2 {
if (width <= 0 || height <= 0) {
throw Exception('Invalid image dimensions.');
}
return _futurize((_Callback<Image> callback) => _toImage(width, height, (_Image image) {
callback(Image._(image));
return _futurize((_Callback<Image?> 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 'Scene_toImage';
String? _toImage(int width, int height, _Callback<_Image?> callback) native 'Scene_toImage';

/// Releases the resources used by this scene.
///
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5239,7 +5239,7 @@ typedef _Callback<T> = void Function(T result);
///
/// Return value should be null on success, and a string error message on
/// failure.
typedef _Callbacker<T> = String? Function(_Callback<T> callback);
typedef _Callbacker<T> = String? Function(_Callback<T?> callback);

/// Converts a method that receives a value-returning callback to a method that
/// returns a Future.
Expand All @@ -5264,7 +5264,7 @@ typedef _Callbacker<T> = String? Function(_Callback<T> callback);
/// ```
Future<T> _futurize<T>(_Callbacker<T> callbacker) {
final Completer<T> completer = Completer<T>.sync();
final String? error = callbacker((T t) {
final String? error = callbacker((T? t) {
if (t == null) {
completer.completeError(Exception('operation failed'));
} else {
Expand Down