[web] Use new APIs from dart:ui_web (#4168)

The following APIs are now exposed through `dart:ui_web` which eliminates the need for shims:
- `platformViewRegistry`
- `webOnlyAssetManager`
- `urlStrategy`

## Issues

* Fixes https://github.com/flutter/flutter/issues/55000

## Minimal `stable` version

THIS PR CANNOT LAND UNTIL THE NEW `dart:ui_web` APIS MAKE IT INTO A STABLE FLUTTER RELEASE.

* Needs 5a7ab5a147
This commit is contained in:
Mouad Debbar
2023-08-30 12:55:12 -04:00
committed by GitHub
parent 5ad43c890d
commit bd97d29f5e
56 changed files with 95 additions and 401 deletions

View File

@ -1,3 +1,8 @@
## 0.3.2+3
* Migrates to `dart:ui_web` APIs.
* Updates minimum supported SDK version to Flutter 3.13.0/Dart 3.1.0.
## 0.3.2+2
* Adds pub topics to package metadata.

View File

@ -5,12 +5,12 @@
import 'dart:async';
import 'dart:html' as html;
import 'dart:ui';
import 'dart:ui_web' as ui_web;
import 'package:camera_platform_interface/camera_platform_interface.dart';
import 'package:flutter/foundation.dart';
import 'camera_service.dart';
import 'shims/dart_ui.dart' as ui;
import 'types/types.dart';
String _getViewType(int cameraId) => 'plugins.flutter.io/camera_$cameraId';
@ -168,7 +168,7 @@ class Camera {
..style.setProperty('object-fit', 'cover')
..append(videoElement);
ui.platformViewRegistry.registerViewFactory(
ui_web.platformViewRegistry.registerViewFactory(
_getViewType(textureId),
(_) => divElement,
);

View File

@ -1,10 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// This file shims dart:ui in web-only scenarios, getting rid of the need to
/// suppress analyzer warnings.
// TODO(ditman): Remove this file once web-only dart:ui APIs are exposed from
// a dedicated place. https://github.com/flutter/flutter/issues/55000
export 'dart_ui_fake.dart' if (dart.library.html) 'dart_ui_real.dart';

View File

@ -1,33 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:html' as html;
// Fake interface for the logic that this package needs from (web-only) dart:ui.
// This is conditionally exported so the analyzer sees these methods as available.
// ignore_for_file: avoid_classes_with_only_static_members
// ignore_for_file: camel_case_types
/// Shim for web_ui engine.PlatformViewRegistry
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/ui.dart#L62
class platformViewRegistry {
/// Shim for registerViewFactory
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/ui.dart#L72
static bool registerViewFactory(
String viewTypeId, html.Element Function(int viewId) viewFactory) {
return false;
}
}
/// Shim for web_ui engine.AssetManager.
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/src/engine/assets.dart#L12
class webOnlyAssetManager {
/// Shim for getAssetUrl.
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/src/engine/assets.dart#L45
static String getAssetUrl(String asset) => '';
}
/// Signature of callbacks that have no arguments and return no data.
typedef VoidCallback = void Function();

View File

@ -1,5 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
export 'dart:ui';

View File

@ -2,11 +2,11 @@ name: camera_web
description: A Flutter plugin for getting information about and controlling the camera on Web.
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.3.2+2
version: 0.3.2+3
environment:
sdk: ">=2.19.0 <4.0.0"
flutter: ">=3.7.0"
sdk: ">=3.1.0 <4.0.0"
flutter: ">=3.13.0"
flutter:
plugin:

View File

@ -1,3 +1,8 @@
## 0.5.4+2
* Migrates to `dart:ui_web` APIs.
* Updates minimum supported SDK version to Flutter 3.13.0/Dart 3.1.0.
## 0.5.4+1
* Adds pub topics to package metadata.

View File

@ -6,8 +6,9 @@ library google_maps_flutter_web;
import 'dart:async';
import 'dart:convert';
import 'dart:html';
import 'dart:html' hide VoidCallback;
import 'dart:js_util';
import 'dart:ui_web' as ui_web;
import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart';
@ -21,7 +22,6 @@ import 'package:sanitize_html/sanitize_html.dart';
import 'package:stream_transform/stream_transform.dart';
import 'src/google_maps_inspector_web.dart';
import 'src/shims/dart_ui.dart' as ui; // Conditionally imports dart:ui in web
import 'src/third_party/to_screen_location/to_screen_location.dart';
import 'src/types.dart';

View File

@ -10,7 +10,7 @@ class CircleController {
CircleController({
required gmaps.Circle circle,
bool consumeTapEvents = false,
ui.VoidCallback? onTap,
VoidCallback? onTap,
}) : _circle = circle,
_consumeTapEvents = consumeTapEvents {
if (onTap != null) {

View File

@ -262,7 +262,7 @@ gmaps.Icon? _gmIconFromBitmapDescriptor(BitmapDescriptor bitmapDescriptor) {
// iconConfig[2] contains the DPIs of the screen, but that information is
// already encoded in the iconConfig[1]
icon = gmaps.Icon()
..url = ui.webOnlyAssetManager.getAssetUrl(iconConfig[1]! as String);
..url = ui_web.assetManager.getAssetUrl(iconConfig[1]! as String);
final gmaps.Size? size = _gmSizeFromIconConfig(iconConfig, 3);
if (size != null) {

View File

@ -41,7 +41,7 @@ class GoogleMapController {
..style.width = '100%'
..style.height = '100%';
ui.platformViewRegistry.registerViewFactory(
ui_web.platformViewRegistry.registerViewFactory(
_getViewType(mapId),
(int viewId) => _div,
);

View File

@ -14,7 +14,7 @@ class MarkerController {
LatLngCallback? onDragStart,
LatLngCallback? onDrag,
LatLngCallback? onDragEnd,
ui.VoidCallback? onTap,
VoidCallback? onTap,
}) : _marker = marker,
_infoWindow = infoWindow,
_consumeTapEvents = consumeTapEvents {

View File

@ -10,7 +10,7 @@ class PolygonController {
PolygonController({
required gmaps.Polygon polygon,
bool consumeTapEvents = false,
ui.VoidCallback? onTap,
VoidCallback? onTap,
}) : _polygon = polygon,
_consumeTapEvents = consumeTapEvents {
if (onTap != null) {

View File

@ -10,7 +10,7 @@ class PolylineController {
PolylineController({
required gmaps.Polyline polyline,
bool consumeTapEvents = false,
ui.VoidCallback? onTap,
VoidCallback? onTap,
}) : _polyline = polyline,
_consumeTapEvents = consumeTapEvents {
if (onTap != null) {

View File

@ -1,10 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// This file shims dart:ui in web-only scenarios, getting rid of the need to
/// suppress analyzer warnings.
// TODO(ditman): Remove this file once web-only dart:ui APIs, https://github.com/flutter/flutter/issues/55000
// are exposed from a dedicated place.
export 'dart_ui_fake.dart' if (dart.library.html) 'dart_ui_real.dart';

View File

@ -1,33 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:html' as html;
// Fake interface for the logic that this package needs from (web-only) dart:ui.
// This is conditionally exported so the analyzer sees these methods as available.
// ignore_for_file: avoid_classes_with_only_static_members
// ignore_for_file: camel_case_types
/// Shim for web_ui engine.PlatformViewRegistry
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/ui.dart#L62
class platformViewRegistry {
/// Shim for registerViewFactory
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/ui.dart#L72
static bool registerViewFactory(
String viewTypeId, html.Element Function(int viewId) viewFactory) {
return false;
}
}
/// Shim for web_ui engine.AssetManager.
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/src/engine/assets.dart#L12
class webOnlyAssetManager {
/// Shim for getAssetUrl.
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/src/engine/assets.dart#L45
static String getAssetUrl(String asset) => '';
}
/// Signature of callbacks that have no arguments and return no data.
typedef VoidCallback = void Function();

View File

@ -1,5 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
export 'dart:ui';

View File

@ -2,11 +2,11 @@ name: google_maps_flutter_web
description: Web platform implementation of google_maps_flutter
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
version: 0.5.4+1
version: 0.5.4+2
environment:
sdk: ">=2.19.0 <4.0.0"
flutter: ">=3.7.0"
sdk: ">=3.1.0 <4.0.0"
flutter: ">=3.13.0"
flutter:
plugin:

View File

@ -1,3 +1,8 @@
## 0.12.0+5
* Migrates to `dart:ui_web` APIs.
* Updates minimum supported SDK version to Flutter 3.13.0/Dart 3.1.0.
## 0.12.0+4
* Adds pub topics to package metadata.

View File

@ -3,7 +3,7 @@
// found in the LICENSE file.
import 'dart:async';
import 'dart:ui' as ui;
import 'dart:ui_web' as ui_web;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
@ -157,8 +157,7 @@ class ResizableFromJs extends StatelessWidget {
this.initialSize,
super.key,
}) {
// ignore: avoid_dynamic_calls, undefined_prefixed_name
ui.platformViewRegistry.registerViewFactory(
ui_web.platformViewRegistry.registerViewFactory(
'resizable_from_js_$instanceId',
(int viewId) {
final DomHtmlElement element = document.createElement('div');

View File

@ -2,8 +2,8 @@ name: google_sign_in_web_integration_tests
publish_to: none
environment:
sdk: ">=2.19.0 <4.0.0"
flutter: ">=3.7.0"
sdk: ">=3.1.0 <4.0.0"
flutter: ">=3.13.0"
dependencies:
cupertino_icons: ^1.0.2

View File

@ -4,7 +4,7 @@
import 'dart:async';
import 'dart:html' as html;
import 'dart:ui' as ui;
import 'dart:ui_web' as ui_web;
import 'package:flutter/foundation.dart' show visibleForTesting, kDebugMode;
import 'package:flutter/material.dart';
@ -172,8 +172,7 @@ class GoogleSignInPlugin extends GoogleSignInPlatform {
// Register a factory for the Button HtmlElementView.
void _registerButtonFactory() {
// ignore: avoid_dynamic_calls, undefined_prefixed_name
ui.platformViewRegistry.registerViewFactory(
ui_web.platformViewRegistry.registerViewFactory(
'gsi_login_button',
(int viewId) {
final DomElement element = createDomElement('div');

View File

@ -3,11 +3,11 @@ description: Flutter plugin for Google Sign-In, a secure authentication system
for signing in with a Google account on Android, iOS and Web.
repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
version: 0.12.0+4
version: 0.12.0+5
environment:
sdk: ">=2.19.0 <4.0.0"
flutter: ">=3.7.0"
sdk: ">=3.1.0 <4.0.0"
flutter: ">=3.13.0"
flutter:
plugin:

View File

@ -1,3 +1,8 @@
## 0.9.3+6
* Migrates to `dart:ui_web` APIs.
* Updates minimum supported SDK version to Flutter 3.13.0/Dart 3.1.0.
## 0.9.3+5
* Adds pub topics to package metadata.

View File

@ -4,12 +4,11 @@
// ignore: avoid_web_libraries_in_flutter
import 'dart:html' as html;
import 'dart:ui_web' as ui_web;
import 'package:flutter/material.dart';
import 'package:pointer_interceptor/pointer_interceptor.dart';
import 'src/shim/dart_ui.dart' as ui;
const String _htmlElementViewType = '_htmlElementViewType';
const double _videoWidth = 640;
const double _videoHeight = 480;
@ -42,7 +41,7 @@ html.Element htmlElement = html.DivElement()
// ..style.border = 'none';
void main() {
ui.platformViewRegistry.registerViewFactory(
ui_web.platformViewRegistry.registerViewFactory(
_htmlElementViewType,
(int viewId) => htmlElement,
);

View File

@ -1,10 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// This file shims dart:ui in web-only scenarios, getting rid of the need to
/// suppress analyzer warnings.
// TODO(dit): flutter/flutter#55000 Remove this file once web-only dart:ui APIs
// are exposed from a dedicated place.
export 'dart_ui_fake.dart' if (dart.library.html) 'dart_ui_real.dart';

View File

@ -1,32 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Fake interface for the logic that this package needs from (web-only) dart:ui.
// This is conditionally exported so the analyzer sees these methods as available.
// ignore: avoid_classes_with_only_static_members
/// Shim for web_ui engine.PlatformViewRegistry
/// https://github.com/flutter/engine/blob/master/lib/web_ui/lib/ui.dart#L62
// ignore: camel_case_types
class platformViewRegistry {
/// Shim for registerViewFactory
/// https://github.com/flutter/engine/blob/master/lib/web_ui/lib/ui.dart#L72
static void registerViewFactory(
String viewTypeId, dynamic Function(int viewId) viewFactory) {}
}
// ignore: avoid_classes_with_only_static_members
/// Shim for web_ui engine.AssetManager.
/// https://github.com/flutter/engine/blob/master/lib/web_ui/lib/src/engine/assets.dart#L12
// ignore: camel_case_types
class webOnlyAssetManager {
/// Shim for getAssetUrl.
/// https://github.com/flutter/engine/blob/master/lib/web_ui/lib/src/engine/assets.dart#L45
static String getAssetUrl(String asset) {
return '';
}
}
/// Signature of callbacks that have no arguments and return no data.
typedef VoidCallback = void Function();

View File

@ -1,5 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
export 'dart:ui';

View File

@ -4,8 +4,8 @@ publish_to: 'none'
version: 1.0.0
environment:
sdk: ">=2.19.0 <4.0.0"
flutter: ">=3.7.0"
sdk: ">=3.1.0 <4.0.0"
flutter: ">=3.13.0"
dependencies:
flutter:

View File

@ -1,10 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// This file shims dart:ui in web-only scenarios, getting rid of the need to
/// suppress analyzer warnings.
// TODO(dit): flutter/flutter#55000 Remove this file once web-only dart:ui APIs
// are exposed from a dedicated place.
export 'dart_ui_fake.dart' if (dart.library.html) 'dart_ui_real.dart';

View File

@ -1,33 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Fake interface for the logic that this package needs from (web-only) dart:ui.
// This is conditionally exported so the analyzer sees these methods as available.
// ignore: avoid_classes_with_only_static_members
/// Shim for web_ui engine.PlatformViewRegistry
/// https://github.com/flutter/engine/blob/master/lib/web_ui/lib/ui.dart#L62
// ignore: camel_case_types
class platformViewRegistry {
/// Shim for registerViewFactory
/// https://github.com/flutter/engine/blob/master/lib/web_ui/lib/ui.dart#L72
static void registerViewFactory(
String viewTypeId, dynamic Function(int viewId) viewFactory,
{bool isVisible = true}) {}
}
// ignore: avoid_classes_with_only_static_members
/// Shim for web_ui engine.AssetManager.
/// https://github.com/flutter/engine/blob/master/lib/web_ui/lib/src/engine/assets.dart#L12
// ignore: camel_case_types
class webOnlyAssetManager {
/// Shim for getAssetUrl.
/// https://github.com/flutter/engine/blob/master/lib/web_ui/lib/src/engine/assets.dart#L45
static String getAssetUrl(String asset) {
return '';
}
}
/// Signature of callbacks that have no arguments and return no data.
typedef VoidCallback = void Function();

View File

@ -1,5 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
export 'dart:ui';

View File

@ -4,11 +4,10 @@
// ignore: avoid_web_libraries_in_flutter
import 'dart:html' as html;
import 'dart:ui_web' as ui_web;
import 'package:flutter/widgets.dart';
import 'shim/dart_ui.dart' as ui;
const String _viewType = '__webPointerInterceptorViewType__';
const String _debug = 'debug__';
@ -20,7 +19,7 @@ String _getViewType({bool debug = false}) {
// Registers a viewFactory for this widget.
void _registerFactory({bool debug = false}) {
final String viewType = _getViewType(debug: debug);
ui.platformViewRegistry.registerViewFactory(viewType, (int viewId) {
ui_web.platformViewRegistry.registerViewFactory(viewType, (int viewId) {
final html.Element htmlElement = html.DivElement()
..style.width = '100%'
..style.height = '100%';

View File

@ -2,11 +2,11 @@ name: pointer_interceptor
description: A widget to prevent clicks from being swallowed by underlying HtmlElementViews on the web.
repository: https://github.com/flutter/packages/tree/main/packages/pointer_interceptor
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+pointer_interceptor%22
version: 0.9.3+5
version: 0.9.3+6
environment:
sdk: ">=2.19.0 <4.0.0"
flutter: ">=3.7.0"
sdk: ">=3.1.0 <4.0.0"
flutter: ">=3.13.0"
dependencies:
flutter:

View File

@ -1,3 +1,8 @@
## 2.0.20
* Migrates to `dart:ui_web` APIs.
* Updates minimum supported SDK version to Flutter 3.13.0/Dart 3.1.0.
## 2.0.19
* Adds pub topics to package metadata.

View File

@ -4,10 +4,10 @@
import 'dart:html' as html;
import 'dart:js_util';
import 'dart:ui_web' as ui_web;
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'package:integration_test/integration_test.dart';
import 'package:url_launcher_platform_interface/link.dart';
import 'package:url_launcher_web/src/link.dart';
@ -69,7 +69,7 @@ void main() {
// Check that internal route properly prepares using the default
// [UrlStrategy]
expect(anchor.getAttribute('href'),
urlStrategy?.prepareExternalUrl(uri3.toString()));
ui_web.urlStrategy?.prepareExternalUrl(uri3.toString()));
expect(anchor.getAttribute('target'), '_self');
// Needed when testing on on Chrome98 headless in CI.

View File

@ -2,8 +2,8 @@ name: regular_integration_tests
publish_to: none
environment:
sdk: ">=2.19.0 <4.0.0"
flutter: ">=3.7.0"
sdk: ">=3.1.0 <4.0.0"
flutter: ">=3.13.0"
dependencies:
flutter:
@ -13,8 +13,6 @@ dev_dependencies:
build_runner: ^2.1.1
flutter_test:
sdk: flutter
flutter_web_plugins:
sdk: flutter
integration_test:
sdk: flutter
mockito: 5.4.1

View File

@ -5,13 +5,13 @@
import 'dart:async';
import 'dart:html' as html;
import 'dart:js_util';
import 'dart:ui_web' as ui_web;
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart' show urlStrategy;
import 'package:url_launcher_platform_interface/link.dart';
/// The unique identifier for the view type to be used for link platform views.
@ -225,7 +225,7 @@ class LinkViewController extends PlatformViewController {
// in case an internal uri is given, the url mus be properly encoded
// using the currently used [UrlStrategy]
if (!uri.hasScheme) {
href = urlStrategy?.prepareExternalUrl(href) ?? href;
href = ui_web.urlStrategy?.prepareExternalUrl(href) ?? href;
}
_element.setAttribute('href', href);
}

View File

@ -1,10 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// This file shims dart:ui in web-only scenarios, getting rid of the need to
/// suppress analyzer warnings.
// TODO(ditman): Remove this file once web-only dart:ui APIs
// are exposed from a dedicated place, flutter/flutter#55000.
export 'dart_ui_fake.dart' if (dart.library.html) 'dart_ui_real.dart';

View File

@ -1,34 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:html' as html;
// Fake interface for the logic that this package needs from (web-only) dart:ui.
// This is conditionally exported so the analyzer sees these methods as available.
// ignore_for_file: avoid_classes_with_only_static_members
// ignore_for_file: camel_case_types
/// Shim for web_ui engine.PlatformViewRegistry
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/ui.dart#L62
class platformViewRegistry {
/// Shim for registerViewFactory
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/ui.dart#L72
static bool registerViewFactory(
String viewTypeId, html.Element Function(int viewId) viewFactory,
{bool isVisible = true}) {
return false;
}
}
/// Shim for web_ui engine.AssetManager.
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/src/engine/assets.dart#L12
class webOnlyAssetManager {
/// Shim for getAssetUrl.
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/src/engine/assets.dart#L45
static String getAssetUrl(String asset) => '';
}
/// Signature of callbacks that have no arguments and return no data.
typedef VoidCallback = void Function();

View File

@ -1,5 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
export 'dart:ui';

View File

@ -4,14 +4,14 @@
import 'dart:async';
import 'dart:html' as html;
import 'dart:ui_web' as ui_web;
import 'package:flutter/foundation.dart' show visibleForTesting;
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart' show Registrar;
import 'package:url_launcher_platform_interface/link.dart';
import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart';
import 'src/link.dart';
import 'src/shims/dart_ui.dart' as ui;
const Set<String> _safariTargetTopSchemes = <String>{
'mailto',
@ -49,7 +49,7 @@ class UrlLauncherPlugin extends UrlLauncherPlatform {
/// Registers this class as the default instance of [UrlLauncherPlatform].
static void registerWith(Registrar registrar) {
UrlLauncherPlatform.instance = UrlLauncherPlugin();
ui.platformViewRegistry
ui_web.platformViewRegistry
.registerViewFactory(linkViewType, linkViewFactory, isVisible: false);
}

View File

@ -2,11 +2,11 @@ name: url_launcher_web
description: Web platform implementation of url_launcher
repository: https://github.com/flutter/packages/tree/main/packages/url_launcher/url_launcher_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+url_launcher%22
version: 2.0.19
version: 2.0.20
environment:
sdk: ">=2.19.0 <4.0.0"
flutter: ">=3.7.0"
sdk: ">=3.1.0 <4.0.0"
flutter: ">=3.13.0"
flutter:
plugin:

View File

@ -1,3 +1,8 @@
## 2.0.18
* Migrates to `dart:ui_web` APIs.
* Updates minimum supported SDK version to Flutter 3.13.0/Dart 3.1.0.
## 2.0.17
* Adds pub topics to package metadata.

View File

@ -1,10 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// This file shims dart:ui in web-only scenarios, getting rid of the need to
/// suppress analyzer warnings.
// TODO(ditman): Remove this file once web-only dart:ui APIs are exposed from
// a dedicated place, https://github.com/flutter/flutter/issues/55000
export 'dart_ui_fake.dart' if (dart.library.html) 'dart_ui_real.dart';

View File

@ -1,33 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:html' as html;
// Fake interface for the logic that this package needs from (web-only) dart:ui.
// This is conditionally exported so the analyzer sees these methods as available.
// ignore_for_file: avoid_classes_with_only_static_members
// ignore_for_file: camel_case_types
/// Shim for web_ui engine.PlatformViewRegistry
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/ui.dart#L62
class platformViewRegistry {
/// Shim for registerViewFactory
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/ui.dart#L72
static bool registerViewFactory(
String viewTypeId, html.Element Function(int viewId) viewFactory) {
return false;
}
}
/// Shim for web_ui engine.AssetManager.
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/src/engine/assets.dart#L12
class webOnlyAssetManager {
/// Shim for getAssetUrl.
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/src/engine/assets.dart#L45
static String getAssetUrl(String asset) => '';
}
/// Signature of callbacks that have no arguments and return no data.
typedef VoidCallback = void Function();

View File

@ -1,5 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
export 'dart:ui';

View File

@ -4,12 +4,12 @@
import 'dart:async';
import 'dart:html';
import 'dart:ui_web' as ui_web;
import 'package:flutter/material.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'package:video_player_platform_interface/video_player_platform_interface.dart';
import 'src/shims/dart_ui.dart' as ui;
import 'src/video_player.dart';
/// The web implementation of [VideoPlayerPlatform].
@ -62,7 +62,7 @@ class VideoPlayerPlugin extends VideoPlayerPlatform {
if (dataSource.package != null && dataSource.package!.isNotEmpty) {
assetUrl = 'packages/${dataSource.package}/$assetUrl';
}
assetUrl = ui.webOnlyAssetManager.getAssetUrl(assetUrl);
assetUrl = ui_web.assetManager.getAssetUrl(assetUrl);
uri = assetUrl;
break;
case DataSourceType.file:
@ -81,7 +81,7 @@ class VideoPlayerPlugin extends VideoPlayerPlatform {
..style.width = '100%';
// TODO(hterkelsen): Use initialization parameters once they are available
ui.platformViewRegistry.registerViewFactory(
ui_web.platformViewRegistry.registerViewFactory(
'videoPlayer-$textureId', (int viewId) => videoElement);
final VideoPlayer player = VideoPlayer(videoElement: videoElement)

View File

@ -2,11 +2,11 @@ name: video_player_web
description: Web platform implementation of video_player.
repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
version: 2.0.17
version: 2.0.18
environment:
sdk: ">=2.19.0 <4.0.0"
flutter: ">=3.7.0"
sdk: ">=3.1.0 <4.0.0"
flutter: ">=3.13.0"
flutter:
plugin:

View File

@ -1,3 +1,8 @@
## 0.2.2+3
* Migrates to `dart:ui_web` APIs.
* Updates minimum supported SDK version to Flutter 3.13.0/Dart 3.1.0.
## 0.2.2+2
* Adds pub topics to package metadata.

View File

@ -1,10 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// This file shims dart:ui in web-only scenarios, getting rid of the need to
/// suppress analyzer warnings.
// TODO(BeMacized): Remove this file once web-only dart:ui APIs,
// are exposed from a dedicated place. flutter/flutter#55000
export 'dart_ui_fake.dart' if (dart.library.html) 'dart_ui_real.dart';

View File

@ -1,33 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:html' as html;
// Fake interface for the logic that this package needs from (web-only) dart:ui.
// This is conditionally exported so the analyzer sees these methods as available.
// ignore_for_file: avoid_classes_with_only_static_members
// ignore_for_file: camel_case_types
/// Shim for web_ui engine.PlatformViewRegistry
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/ui.dart#L62
class platformViewRegistry {
/// Shim for registerViewFactory
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/ui.dart#L72
static bool registerViewFactory(
String viewTypeId, html.Element Function(int viewId) viewFactory) {
return false;
}
}
/// Shim for web_ui engine.AssetManager.
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/src/engine/assets.dart#L12
class webOnlyAssetManager {
/// Shim for getAssetUrl.
/// https://github.com/flutter/engine/blob/main/lib/web_ui/lib/src/engine/assets.dart#L45
static String getAssetUrl(String asset) => '';
}
/// Signature of callbacks that have no arguments and return no data.
typedef VoidCallback = void Function();

View File

@ -1,5 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
export 'dart:ui';

View File

@ -4,13 +4,13 @@
import 'dart:convert';
import 'dart:html' as html;
import 'dart:ui_web' as ui_web;
import 'package:flutter/cupertino.dart';
import 'package:webview_flutter_platform_interface/webview_flutter_platform_interface.dart';
import 'content_type.dart';
import 'http_request_factory.dart';
import 'shims/dart_ui.dart' as ui;
/// An implementation of [PlatformWebViewControllerCreationParams] using Flutter
/// for Web API.
@ -115,7 +115,7 @@ class WebWebViewWidget extends PlatformWebViewWidget {
: super.implementation(params) {
final WebWebViewController controller =
params.controller as WebWebViewController;
ui.platformViewRegistry.registerViewFactory(
ui_web.platformViewRegistry.registerViewFactory(
controller._webWebViewParams.iFrame.id,
(int viewId) => controller._webWebViewParams.iFrame,
);

View File

@ -5,6 +5,8 @@
import 'dart:async';
import 'dart:convert';
import 'dart:html';
import 'dart:ui_web' as ui_web;
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/widgets.dart';
@ -12,7 +14,6 @@ import 'package:flutter_web_plugins/flutter_web_plugins.dart';
// ignore: implementation_imports
import 'package:webview_flutter_platform_interface/src/webview_flutter_platform_interface_legacy.dart';
import 'http_request_factory.dart';
import 'shims/dart_ui.dart' as ui;
/// Builds an iframe based WebView.
///
@ -20,7 +21,7 @@ import 'shims/dart_ui.dart' as ui;
class WebWebViewPlatform implements WebViewPlatform {
/// Constructs a new instance of [WebWebViewPlatform].
WebWebViewPlatform() {
ui.platformViewRegistry.registerViewFactory(
ui_web.platformViewRegistry.registerViewFactory(
'webview-iframe',
(int viewId) => IFrameElement()
..id = 'webview-$viewId'

View File

@ -2,11 +2,11 @@ name: webview_flutter_web
description: A Flutter plugin that provides a WebView widget on web.
repository: https://github.com/flutter/packages/tree/main/packages/webview_flutter/webview_flutter_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22
version: 0.2.2+2
version: 0.2.2+3
environment:
sdk: ">=2.19.0 <4.0.0"
flutter: ">=3.7.0"
sdk: ">=3.1.0 <4.0.0"
flutter: ">=3.13.0"
flutter:
plugin: