Unverified Commit 9a9c2826 authored by Mouad Debbar's avatar Mouad Debbar Committed by GitHub

[web] Migrate remaining web-only API usages to `dart:ui_web` (#132248)

This is the last batch of web-only API migration.

Depends on https://github.com/flutter/engine/pull/44516

Fixes https://github.com/flutter/flutter/issues/52899
Fixes https://github.com/flutter/flutter/issues/126831
parent ff829fd8
......@@ -5,6 +5,7 @@
import 'dart:async';
import 'dart:js_interop';
import 'dart:ui' as ui;
import 'dart:ui_web' as ui_web;
import 'package:flutter/foundation.dart';
import 'package:web/web.dart' as web;
......@@ -117,8 +118,8 @@ class NetworkImage
}
// Html renderer does not support decoding network images to a specified size. The decode parameter
// here is ignored and the web-only `ui.webOnlyInstantiateImageCodecFromUrl` will be used
// directly in place of the typical `instantiateImageCodec` method.
// here is ignored and `ui_web.createImageCodecFromUrl` will be used directly
// in place of the typical `instantiateImageCodec` method.
Future<ui.Codec> _loadAsync(
NetworkImage key,
image_provider.ImageDecoderCallback? decode,
......@@ -133,7 +134,7 @@ class NetworkImage
final bool containsNetworkImageHeaders = key.headers?.isNotEmpty ?? false;
// We use a different method when headers are set because the
// `ui.webOnlyInstantiateImageCodecFromUrl` method is not capable of handling headers.
// `ui_web.createImageCodecFromUrl` method is not capable of handling headers.
if (isCanvasKit || containsNetworkImageHeaders) {
final Completer<web.XMLHttpRequest> completer =
Completer<web.XMLHttpRequest>();
......@@ -190,16 +191,13 @@ class NetworkImage
return decodeDeprecated!(bytes);
}
} else {
// This API only exists in the web engine implementation and is not
// contained in the analyzer summary for Flutter.
// ignore: undefined_function, avoid_dynamic_calls
return ui.webOnlyInstantiateImageCodecFromUrl(
return ui_web.createImageCodecFromUrl(
resolved,
chunkCallback: (int bytes, int total) {
chunkEvents.add(ImageChunkEvent(
cumulativeBytesLoaded: bytes, expectedTotalBytes: total));
},
) as Future<ui.Codec>;
);
}
}
......
......@@ -231,8 +231,8 @@ String generateTestEntrypoint({
ui_web.debugEmulateFlutterTesterEnvironment = true;
await ui_web.bootstrapEngine();
webGoldenComparator = DefaultWebGoldenComparator(Uri.parse('${Uri.file(absolutePath)}'));
(ui.window as dynamic).debugOverrideDevicePixelRatio(3.0);
(ui.window as dynamic).webOnlyDebugPhysicalSizeOverride = const ui.Size(2400, 1800);
ui_web.debugOverrideDevicePixelRatio(3.0);
ui.window.debugPhysicalSizeOverride = const ui.Size(2400, 1800);
internalBootstrapBrowserTest(() {
return ${testConfigPath != null ? "() => test_config.testExecutable(test.main)" : "test.main"};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment