Skip to content

Commit

Permalink
Import web-only APIs from dart:ui_web (flutter#5942)
Browse files Browse the repository at this point in the history
These web-only APIs are now exported properly through `dart:ui_web`.

Related to: flutter/flutter#126831
  • Loading branch information
mdebbar committed Jun 26, 2023
1 parent ddc8b5a commit 063ed2a
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'dart:async';
// ignore: avoid_web_libraries_in_flutter, as designed
import 'dart:html' as html;
import 'dart:ui' as ui;
import 'dart:ui_web' as ui_web;

import 'package:flutter/foundation.dart';

Expand All @@ -31,7 +31,7 @@ const _debugUseLocalPerfetto = false;
/// app and for each load of offline data. Each time [PerfettoController.init]
/// is called, we create a new [html.IFrameElement] and register it to
/// [PerfettoController.viewId] via
/// [ui.platformViewRegistry.registerViewFactory]. Each new [html.IFrameElement]
/// [ui_web.platformViewRegistry.registerViewFactory]. Each new [html.IFrameElement]
/// must have a unique id in the [PlatformViewRegistry], which
/// [_viewIdIncrementer] is used to create.
var _viewIdIncrementer = 0;
Expand Down Expand Up @@ -123,8 +123,7 @@ class PerfettoControllerImpl extends PerfettoController {
origin: html.window.location.origin,
path: html.window.location.pathname ?? '',
);
// ignore: undefined_prefixed_name, doesn't understand conditional imports.
final indexFilePath = ui.webOnlyAssetManager
final indexFilePath = ui_web.assetManager
.getAssetUrl(devToolsExtensionPoints.perfettoIndexLocation);
final baseUrl = '$basePath/$indexFilePath';
return '$baseUrl$_embeddedModeQuery';
Expand Down Expand Up @@ -178,10 +177,7 @@ class PerfettoControllerImpl extends PerfettoController {
..height = '100%'
..width = '100%';

// This ignore is required due to
// https://github.com/flutter/flutter/issues/41563
// ignore: undefined_prefixed_name
final registered = ui.platformViewRegistry.registerViewFactory(
final registered = ui_web.platformViewRegistry.registerViewFactory(
viewId,
(int viewId) => _perfettoIFrame,
);
Expand Down

0 comments on commit 063ed2a

Please sign in to comment.