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