3
3
// found in the LICENSE file.
4
4
5
5
import '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' ;
8
11
import 'dart:math' as math;
9
12
import 'dart:ui' ;
10
13
@@ -15,6 +18,7 @@ import 'package:flutter/scheduler.dart';
15
18
import 'package:flutter/services.dart' ;
16
19
import 'package:flutter/widgets.dart' ;
17
20
import 'package:meta/meta.dart' ;
21
+ import 'package:web/web.dart' as web;
18
22
19
23
/// The default number of samples from warm-up iterations.
20
24
///
@@ -1253,7 +1257,7 @@ void startMeasureFrame(Profile profile) {
1253
1257
1254
1258
if (! profile.isWarmingUp) {
1255
1259
// 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 );
1257
1261
1258
1262
_isMeasuringFrame = true ;
1259
1263
}
@@ -1276,11 +1280,11 @@ void endMeasureFrame() {
1276
1280
1277
1281
if (_isMeasuringFrame) {
1278
1282
// 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 ,
1284
1288
);
1285
1289
1286
1290
// Increment the current frame number.
@@ -1310,7 +1314,10 @@ void registerEngineBenchmarkValueListener(String name, EngineBenchmarkValueListe
1310
1314
1311
1315
if (_engineBenchmarkListeners.isEmpty) {
1312
1316
// 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;
1314
1321
}
1315
1322
1316
1323
_engineBenchmarkListeners[name] = listener;
@@ -1321,7 +1328,7 @@ void stopListeningToEngineBenchmarkValues(String name) {
1321
1328
_engineBenchmarkListeners.remove (name);
1322
1329
if (_engineBenchmarkListeners.isEmpty) {
1323
1330
// 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 ;
1325
1332
}
1326
1333
}
1327
1334
0 commit comments