33// found in the LICENSE file.
44
55import 'dart:async' ;
6- import 'dart:html' as html;
7- import 'dart:js_util' as js_util;
6+ import 'dart:js_interop' ;
7+ // The analyzer currently thinks `js_interop_unsafe` is unused, but it is used
8+ // for `JSObject.[]=`.
9+ // ignore: unused_import
10+ import 'dart:js_interop_unsafe' ;
811import 'dart:math' as math;
912import 'dart:ui' ;
1013
@@ -15,6 +18,7 @@ import 'package:flutter/scheduler.dart';
1518import 'package:flutter/services.dart' ;
1619import 'package:flutter/widgets.dart' ;
1720import 'package:meta/meta.dart' ;
21+ import 'package:web/web.dart' as web;
1822
1923/// The default number of samples from warm-up iterations.
2024///
@@ -1253,7 +1257,7 @@ void startMeasureFrame(Profile profile) {
12531257
12541258 if (! profile.isWarmingUp) {
12551259 // Tell the browser to mark the beginning of the frame.
1256- html .window.performance.mark ('measured_frame_start#$_currentFrameNumber ' );
1260+ web .window.performance.mark ('measured_frame_start#$_currentFrameNumber ' .toJS );
12571261
12581262 _isMeasuringFrame = true ;
12591263 }
@@ -1276,11 +1280,11 @@ void endMeasureFrame() {
12761280
12771281 if (_isMeasuringFrame) {
12781282 // Tell the browser to mark the end of the frame, and measure the duration.
1279- html .window.performance.mark ('measured_frame_end#$_currentFrameNumber ' );
1280- html .window.performance.measure (
1281- 'measured_frame' ,
1282- 'measured_frame_start#$_currentFrameNumber ' ,
1283- 'measured_frame_end#$_currentFrameNumber ' ,
1283+ web .window.performance.mark ('measured_frame_end#$_currentFrameNumber ' .toJS );
1284+ web .window.performance.measure (
1285+ 'measured_frame' .toJS ,
1286+ 'measured_frame_start#$_currentFrameNumber ' .toJS ,
1287+ 'measured_frame_end#$_currentFrameNumber ' .toJS ,
12841288 );
12851289
12861290 // Increment the current frame number.
@@ -1310,7 +1314,10 @@ void registerEngineBenchmarkValueListener(String name, EngineBenchmarkValueListe
13101314
13111315 if (_engineBenchmarkListeners.isEmpty) {
13121316 // The first listener is being registered. Register the global listener.
1313- js_util.setProperty (html.window, '_flutter_internal_on_benchmark' , _dispatchEngineBenchmarkValue);
1317+ web.window['_flutter_internal_on_benchmark' .toJS] =
1318+ // Upcast to [Object] to export.
1319+ // ignore: unnecessary_cast
1320+ (_dispatchEngineBenchmarkValue as Object ).toJS;
13141321 }
13151322
13161323 _engineBenchmarkListeners[name] = listener;
@@ -1321,7 +1328,7 @@ void stopListeningToEngineBenchmarkValues(String name) {
13211328 _engineBenchmarkListeners.remove (name);
13221329 if (_engineBenchmarkListeners.isEmpty) {
13231330 // The last listener unregistered. Remove the global listener.
1324- js_util. setProperty (html. window, '_flutter_internal_on_benchmark' , null ) ;
1331+ web. window[ '_flutter_internal_on_benchmark' .toJS] = null ;
13251332 }
13261333}
13271334
0 commit comments