Use PlatformDispatcher.instance over window where possible (#99496)

This commit is contained in:
Michael Goderbauer
2022-03-03 14:46:16 -08:00
committed by GitHub
parent a4aeb77876
commit 7f2c1cd772
38 changed files with 175 additions and 197 deletions

View File

@@ -122,6 +122,7 @@ void beginFrame(Duration timeStamp) {
}
void main() {
ui.window.onBeginFrame = beginFrame;
ui.window.scheduleFrame();
ui.PlatformDispatcher.instance
..onBeginFrame = beginFrame
..scheduleFrame();
}

View File

@@ -42,9 +42,9 @@ void beginFrame(Duration timeStamp) {
// calls main() as soon as it has loaded your code.
void main() {
// The engine calls onBeginFrame whenever it wants us to produce a frame.
ui.window.onBeginFrame = beginFrame;
ui.PlatformDispatcher.instance.onBeginFrame = beginFrame;
// Here we kick off the whole process by asking the engine to schedule a new
// frame. The engine will eventually call onBeginFrame when it is time for us
// to actually produce the frame.
ui.window.scheduleFrame();
ui.PlatformDispatcher.instance.scheduleFrame();
}

View File

@@ -52,10 +52,11 @@ void beginFrame(Duration timeStamp) {
// After rendering the current frame of the animation, we ask the engine to
// schedule another frame. The engine will call beginFrame again when its time
// to produce the next frame.
ui.window.scheduleFrame();
ui.PlatformDispatcher.instance.scheduleFrame();
}
void main() {
ui.window.onBeginFrame = beginFrame;
ui.window.scheduleFrame();
ui.PlatformDispatcher.instance
..onBeginFrame = beginFrame
..scheduleFrame();
}

View File

@@ -89,6 +89,7 @@ void main() {
..layout(const ui.ParagraphConstraints(width: 180.0));
// Finally, we register our beginFrame callback and kick off the first frame.
ui.window.onBeginFrame = beginFrame;
ui.window.scheduleFrame();
ui.PlatformDispatcher.instance
..onBeginFrame = beginFrame
..scheduleFrame();
}

View File

@@ -94,7 +94,7 @@ void handlePointerDataPacket(ui.PointerDataPacket packet) {
// point where the engine calls onBeginFrame, which signals the boundary
// between one frame and another.
color = const ui.Color(0xFF00FF00);
ui.window.scheduleFrame();
ui.PlatformDispatcher.instance.scheduleFrame();
}
}
}
@@ -104,12 +104,12 @@ void handlePointerDataPacket(ui.PointerDataPacket packet) {
void main() {
color = const ui.Color(0xFF00FF00);
// The engine calls onBeginFrame whenever it wants us to produce a frame.
ui.window.onBeginFrame = beginFrame;
ui.PlatformDispatcher.instance.onBeginFrame = beginFrame;
// The engine calls onPointerDataPacket whenever it had updated information
// about the pointers directed at our app.
ui.window.onPointerDataPacket = handlePointerDataPacket;
ui.PlatformDispatcher.instance.onPointerDataPacket = handlePointerDataPacket;
// Here we kick off the whole process by asking the engine to schedule a new
// frame. The engine will eventually call onBeginFrame when it is time for us
// to actually produce the frame.
ui.window.scheduleFrame();
ui.PlatformDispatcher.instance.scheduleFrame();
}