From 9b0a2f580443111aa456300858f5900ba0796bbb Mon Sep 17 00:00:00 2001 From: Srujan Gaddam Date: Thu, 16 Nov 2023 09:02:13 -0800 Subject: [PATCH 1/2] Pin package:web 0.4.0 Now that Flutter main has moved to ^0.4.0, we can pin this version. --- .../lib/src/extensions/embedded/_controller_web.dart | 4 +--- .../perfetto/_perfetto_controller_web.dart | 4 +--- .../lib/src/shared/config_specific/analysis_options.yaml | 6 ------ .../config_specific/notifications/_notifications_web.dart | 8 ++++---- .../config_specific/post_message/_post_message_web.dart | 7 +------ packages/devtools_app/pubspec.yaml | 2 +- packages/devtools_app_shared/pubspec.yaml | 2 +- packages/devtools_extensions/pubspec.yaml | 2 +- 8 files changed, 10 insertions(+), 25 deletions(-) delete mode 100644 packages/devtools_app/lib/src/shared/config_specific/analysis_options.yaml diff --git a/packages/devtools_app/lib/src/extensions/embedded/_controller_web.dart b/packages/devtools_app/lib/src/extensions/embedded/_controller_web.dart index 57e7ba58ba1..da221abd3e5 100644 --- a/packages/devtools_app/lib/src/extensions/embedded/_controller_web.dart +++ b/packages/devtools_app/lib/src/extensions/embedded/_controller_web.dart @@ -74,9 +74,7 @@ class EmbeddedExtensionControllerImpl extends EmbeddedExtensionController ); _initialized = true; - // TODO(kenz): replace with `createIFrameElement` when we upgrade to - // package:web ^0.3.1. - _extensionIFrame = createElementTag('iframe') as HTMLIFrameElement + _extensionIFrame = createIFrameElement() // This url is safe because we built it ourselves and it does not include // any user input. // ignore: unsafe_html diff --git a/packages/devtools_app/lib/src/screens/performance/panes/timeline_events/perfetto/_perfetto_controller_web.dart b/packages/devtools_app/lib/src/screens/performance/panes/timeline_events/perfetto/_perfetto_controller_web.dart index 31fd9e9b6a8..e4ba4eb22b7 100644 --- a/packages/devtools_app/lib/src/screens/performance/panes/timeline_events/perfetto/_perfetto_controller_web.dart +++ b/packages/devtools_app/lib/src/screens/performance/panes/timeline_events/perfetto/_perfetto_controller_web.dart @@ -165,9 +165,7 @@ class PerfettoControllerImpl extends PerfettoController { ); _initialized = true; - // TODO(kenz): replace with `createIFrameElement` when we upgrade to - // package:web ^0.3.1. - _perfettoIFrame = createElementTag('iframe') as HTMLIFrameElement + _perfettoIFrame = createIFrameElement() // This url is safe because we built it ourselves and it does not include // any user input. // ignore: unsafe_html diff --git a/packages/devtools_app/lib/src/shared/config_specific/analysis_options.yaml b/packages/devtools_app/lib/src/shared/config_specific/analysis_options.yaml deleted file mode 100644 index 73fe07731c1..00000000000 --- a/packages/devtools_app/lib/src/shared/config_specific/analysis_options.yaml +++ /dev/null @@ -1,6 +0,0 @@ -include: ../../../../analysis_options.yaml - -linter: - rules: - # For some reasons this doesn't work: https://github.com/dart-lang/linter/issues/4308 - avoid_web_libraries_in_flutter: false diff --git a/packages/devtools_app/lib/src/shared/config_specific/notifications/_notifications_web.dart b/packages/devtools_app/lib/src/shared/config_specific/notifications/_notifications_web.dart index 36e52d18fd9..b0617d28940 100644 --- a/packages/devtools_app/lib/src/shared/config_specific/notifications/_notifications_web.dart +++ b/packages/devtools_app/lib/src/shared/config_specific/notifications/_notifications_web.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file. -import 'dart:js_util'; +import 'dart:js_interop'; import 'package:web/helpers.dart' as web_helpers; import 'package:web/web.dart'; @@ -17,9 +17,9 @@ class Notification { late final web_helpers.Notification _impl; - static Future requestPermission() { - return promiseToFuture(web_helpers.Notification.requestPermission()); - } + static Future requestPermission() async => + ((await web_helpers.Notification.requestPermission().toDart) as JSString) + .toDart; void close() { _impl.close(); diff --git a/packages/devtools_app/lib/src/shared/config_specific/post_message/_post_message_web.dart b/packages/devtools_app/lib/src/shared/config_specific/post_message/_post_message_web.dart index a3a9ae0b520..eca075b56b4 100644 --- a/packages/devtools_app/lib/src/shared/config_specific/post_message/_post_message_web.dart +++ b/packages/devtools_app/lib/src/shared/config_specific/post_message/_post_message_web.dart @@ -2,11 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file. -// TODO(https://github.com/flutter/devtools/issues/6606): remove this import. -// This is the final dart:html import in DevTools. In order to remove it, we -// need to bump the `package:web` version in DevTools to > 0.3.1, but we are -// blocked on `package:web` rolling into the Flutter SDK. -import 'dart:html' as html; import 'dart:js_interop'; import 'package:web/helpers.dart'; @@ -14,7 +9,7 @@ import 'package:web/helpers.dart'; import 'post_message.dart'; Stream get onPostMessage { - return html.window.onMessage.map( + return window.onMessage.map( (message) => PostMessageEvent( origin: message.origin, data: message.data, diff --git a/packages/devtools_app/pubspec.yaml b/packages/devtools_app/pubspec.yaml index 11449498cd4..d207c38fc28 100644 --- a/packages/devtools_app/pubspec.yaml +++ b/packages/devtools_app/pubspec.yaml @@ -66,7 +66,7 @@ dependencies: vm_service: ^13.0.0 # TODO https://github.com/dart-lang/sdk/issues/52853 - unpin this version vm_snapshot_analysis: 0.7.2 - web: '>=0.3.0 <0.5.0' + web: ^0.4.0 web_socket_channel: ^2.1.0 # widget_icons: ^0.0.1 diff --git a/packages/devtools_app_shared/pubspec.yaml b/packages/devtools_app_shared/pubspec.yaml index 216c5e3429f..23d08746a41 100644 --- a/packages/devtools_app_shared/pubspec.yaml +++ b/packages/devtools_app_shared/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: meta: ^1.9.1 pointer_interceptor: ^0.9.3+3 vm_service: ^13.0.0 - web: '>=0.3.0 <0.5.0' + web: ^0.4.0 dev_dependencies: flutter_lints: ^2.0.3 diff --git a/packages/devtools_extensions/pubspec.yaml b/packages/devtools_extensions/pubspec.yaml index 748460966c6..60c22f85654 100644 --- a/packages/devtools_extensions/pubspec.yaml +++ b/packages/devtools_extensions/pubspec.yaml @@ -21,7 +21,7 @@ dependencies: path: ^1.8.0 logging: ^1.1.1 vm_service: ^13.0.0 - web: '>=0.3.0 <0.5.0' + web: ^0.4.0 dev_dependencies: flutter_driver: From 270947f5b9a2255dc443e30b66dee3f10680bd3f Mon Sep 17 00:00:00 2001 From: Srujan Gaddam Date: Mon, 20 Nov 2023 11:54:35 -0800 Subject: [PATCH 2/2] Remove unnecessary lints --- .../shared/config_specific/import_export/_export_web.dart | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/devtools_app/lib/src/shared/config_specific/import_export/_export_web.dart b/packages/devtools_app/lib/src/shared/config_specific/import_export/_export_web.dart index a13ece02586..5abfde47722 100644 --- a/packages/devtools_app/lib/src/shared/config_specific/import_export/_export_web.dart +++ b/packages/devtools_app/lib/src/shared/config_specific/import_export/_export_web.dart @@ -23,16 +23,10 @@ class ExportControllerWeb extends ExportController { final element = document.createElement('a') as HTMLAnchorElement; element.setAttribute( 'href', - // TODO(srujzs): This is necessary in order to support package:web 0.4.0. - // This was not needed with 0.3.0, hence the lint. - // ignore: avoid-unnecessary-type-casts URL.createObjectURL(Blob([content.toJS].toJS) as JSObject), ); element.setAttribute('download', fileName); element.style.display = 'none'; - // TODO(srujzs): This is necessary in order to support package:web 0.4.0. - // This was not needed with 0.3.0, hence the lint. - // ignore: avoid-unnecessary-type-casts (document.body as HTMLBodyElement).append(element as JSAny); element.click(); element.remove();