Skip to content

Commit 9a9c282

Browse files
authored
[web] Migrate remaining web-only API usages to dart:ui_web (#132248)
This is the last batch of web-only API migration. Depends on flutter/engine#44516 Fixes flutter/flutter#52899 Fixes flutter/flutter#126831
1 parent ff829fd commit 9a9c282

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

packages/flutter/lib/src/painting/_network_image_web.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import 'dart:async';
66
import 'dart:js_interop';
77
import 'dart:ui' as ui;
8+
import 'dart:ui_web' as ui_web;
89

910
import 'package:flutter/foundation.dart';
1011
import 'package:web/web.dart' as web;
@@ -117,8 +118,8 @@ class NetworkImage
117118
}
118119

119120
// Html renderer does not support decoding network images to a specified size. The decode parameter
120-
// here is ignored and the web-only `ui.webOnlyInstantiateImageCodecFromUrl` will be used
121-
// directly in place of the typical `instantiateImageCodec` method.
121+
// here is ignored and `ui_web.createImageCodecFromUrl` will be used directly
122+
// in place of the typical `instantiateImageCodec` method.
122123
Future<ui.Codec> _loadAsync(
123124
NetworkImage key,
124125
image_provider.ImageDecoderCallback? decode,
@@ -133,7 +134,7 @@ class NetworkImage
133134
final bool containsNetworkImageHeaders = key.headers?.isNotEmpty ?? false;
134135

135136
// We use a different method when headers are set because the
136-
// `ui.webOnlyInstantiateImageCodecFromUrl` method is not capable of handling headers.
137+
// `ui_web.createImageCodecFromUrl` method is not capable of handling headers.
137138
if (isCanvasKit || containsNetworkImageHeaders) {
138139
final Completer<web.XMLHttpRequest> completer =
139140
Completer<web.XMLHttpRequest>();
@@ -190,16 +191,13 @@ class NetworkImage
190191
return decodeDeprecated!(bytes);
191192
}
192193
} else {
193-
// This API only exists in the web engine implementation and is not
194-
// contained in the analyzer summary for Flutter.
195-
// ignore: undefined_function, avoid_dynamic_calls
196-
return ui.webOnlyInstantiateImageCodecFromUrl(
194+
return ui_web.createImageCodecFromUrl(
197195
resolved,
198196
chunkCallback: (int bytes, int total) {
199197
chunkEvents.add(ImageChunkEvent(
200198
cumulativeBytesLoaded: bytes, expectedTotalBytes: total));
201199
},
202-
) as Future<ui.Codec>;
200+
);
203201
}
204202
}
205203

packages/flutter_tools/lib/src/web/bootstrap.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ String generateTestEntrypoint({
231231
ui_web.debugEmulateFlutterTesterEnvironment = true;
232232
await ui_web.bootstrapEngine();
233233
webGoldenComparator = DefaultWebGoldenComparator(Uri.parse('${Uri.file(absolutePath)}'));
234-
(ui.window as dynamic).debugOverrideDevicePixelRatio(3.0);
235-
(ui.window as dynamic).webOnlyDebugPhysicalSizeOverride = const ui.Size(2400, 1800);
234+
ui_web.debugOverrideDevicePixelRatio(3.0);
235+
ui.window.debugPhysicalSizeOverride = const ui.Size(2400, 1800);
236236
237237
internalBootstrapBrowserTest(() {
238238
return ${testConfigPath != null ? "() => test_config.testExecutable(test.main)" : "test.main"};

0 commit comments

Comments
 (0)