forked from firka/flutter
[web] Migrate web-only initialization APIs (#129856)
- `ui_web.warmupEngine` - `ui_web.setPluginHandler` - `ui_web.debugEmulateFlutterTesterEnvironment`
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:ui_web' as ui_web;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -57,13 +58,11 @@ class Registrar extends BinaryMessenger {
|
||||
/// previously-registered handler and replaces it with the handler
|
||||
/// from this object.
|
||||
///
|
||||
/// This method uses a function called `webOnlySetPluginHandler` in
|
||||
/// the [dart:ui] library. That function is only available when
|
||||
/// This method uses a function called `setPluginHandler` in
|
||||
/// the [dart:ui_web] library. That function is only available when
|
||||
/// compiling for the web.
|
||||
void registerMessageHandler() {
|
||||
// The `ui.webOnlySetPluginHandler` function below is only defined in the Web dart:ui.
|
||||
// ignore: undefined_function, avoid_dynamic_calls
|
||||
ui.webOnlySetPluginHandler(handleFrameworkMessage);
|
||||
ui_web.setPluginHandler(handleFrameworkMessage);
|
||||
}
|
||||
|
||||
/// Receives a platform message from the framework.
|
||||
@@ -101,7 +100,7 @@ class Registrar extends BinaryMessenger {
|
||||
/// the following:
|
||||
///
|
||||
/// ```dart
|
||||
/// ui.webOnlySetPluginHandler(webPluginRegistrar.handleFrameworkMessage);
|
||||
/// ui_web.setPluginHandler(handleFrameworkMessage);
|
||||
/// ```
|
||||
Future<void> handleFrameworkMessage(
|
||||
String channel,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
library;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:ui_web' as ui_web;
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -14,7 +14,7 @@ import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
||||
|
||||
void main() {
|
||||
// Disabling tester emulation because this test relies on real message channel communication.
|
||||
ui.debugEmulateFlutterTesterEnvironment = false; // ignore: undefined_prefixed_name
|
||||
ui_web.debugEmulateFlutterTesterEnvironment = false;
|
||||
|
||||
group('Plugin Event Channel', () {
|
||||
setUp(() {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
@TestOn('chrome') // Uses web-only Flutter SDK
|
||||
library;
|
||||
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:ui_web' as ui_web;
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -31,7 +31,7 @@ class TestPlugin {
|
||||
|
||||
void main() {
|
||||
// Disabling tester emulation because this test relies on real message channel communication.
|
||||
ui.debugEmulateFlutterTesterEnvironment = false; // ignore: undefined_prefixed_name
|
||||
ui_web.debugEmulateFlutterTesterEnvironment = false;
|
||||
|
||||
group('Plugin Registry', () {
|
||||
setUp(() {
|
||||
|
||||
Reference in New Issue
Block a user