Use PlatformDispatcher.instance over window where possible (#99496)
This commit is contained in:
committed by
GitHub
parent
a4aeb77876
commit
7f2c1cd772
@@ -262,7 +262,7 @@ abstract class SceneBuilderRecorder extends Recorder {
|
||||
final Completer<Profile> profileCompleter = Completer<Profile>();
|
||||
_profile = Profile(name: name);
|
||||
|
||||
window.onBeginFrame = (_) {
|
||||
PlatformDispatcher.instance.onBeginFrame = (_) {
|
||||
try {
|
||||
startMeasureFrame(profile!);
|
||||
onBeginFrame();
|
||||
@@ -271,7 +271,7 @@ abstract class SceneBuilderRecorder extends Recorder {
|
||||
rethrow;
|
||||
}
|
||||
};
|
||||
window.onDrawFrame = () {
|
||||
PlatformDispatcher.instance.onDrawFrame = () {
|
||||
try {
|
||||
_profile!.record('drawFrameDuration', () {
|
||||
final SceneBuilder sceneBuilder = SceneBuilder();
|
||||
@@ -286,7 +286,7 @@ abstract class SceneBuilderRecorder extends Recorder {
|
||||
endMeasureFrame();
|
||||
|
||||
if (shouldContinue()) {
|
||||
window.scheduleFrame();
|
||||
PlatformDispatcher.instance.scheduleFrame();
|
||||
} else {
|
||||
profileCompleter.complete(_profile);
|
||||
}
|
||||
@@ -295,7 +295,7 @@ abstract class SceneBuilderRecorder extends Recorder {
|
||||
rethrow;
|
||||
}
|
||||
};
|
||||
window.scheduleFrame();
|
||||
PlatformDispatcher.instance.scheduleFrame();
|
||||
return profileCompleter.future;
|
||||
}
|
||||
}
|
||||
@@ -403,7 +403,7 @@ abstract class WidgetRecorder extends Recorder implements FrameRecorder {
|
||||
profile!.addDataPoint('drawFrameDuration', _drawFrameStopwatch.elapsed, reported: true);
|
||||
|
||||
if (shouldContinue()) {
|
||||
window.scheduleFrame();
|
||||
PlatformDispatcher.instance.scheduleFrame();
|
||||
} else {
|
||||
for (final VoidCallback fn in _didStopCallbacks)
|
||||
fn();
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as ui show window;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stocks/main.dart' as stocks;
|
||||
@@ -61,8 +59,8 @@ void main() {
|
||||
expect(find.text('Account Balance'), findsNothing);
|
||||
|
||||
// drag the drawer out
|
||||
final Offset left = Offset(0.0, (ui.window.physicalSize / ui.window.devicePixelRatio).height / 2.0);
|
||||
final Offset right = Offset((ui.window.physicalSize / ui.window.devicePixelRatio).width, left.dy);
|
||||
final Offset left = Offset(0.0, (WidgetsBinding.instance.window.physicalSize / WidgetsBinding.instance.window.devicePixelRatio).height / 2.0);
|
||||
final Offset right = Offset((WidgetsBinding.instance.window.physicalSize / WidgetsBinding.instance.window.devicePixelRatio).width, left.dy);
|
||||
final TestGesture gesture = await tester.startGesture(left);
|
||||
await tester.pump();
|
||||
await gesture.moveTo(right);
|
||||
|
||||
Reference in New Issue
Block a user