scheduleWarmUpFrame method

void scheduleWarmUpFrame({
  1. required VoidCallback beginFrame,
  2. required VoidCallback drawFrame,
})

Schedule a frame to run as soon as possible, rather than waiting for the engine to request a frame in response to a system "Vsync" signal.

The application can call this method as soon as it starts up so that the first frame (which is likely to be quite expensive) can start a few extra milliseconds earlier. Using it in other situations might lead to unintended results, such as screen tearing. Depending on platforms and situations, the warm up frame might or might not be actually rendered onto the screen.

For more introduction to the warm up frame, see SchedulerBinding.scheduleWarmUpFrame.

This method uses the provided callbacks as the begin frame callback and the draw frame callback instead of onBeginFrame and onDrawFrame.

See also:

Implementation

void scheduleWarmUpFrame({required VoidCallback beginFrame, required VoidCallback drawFrame}) {
  // We use timers here to ensure that microtasks flush in between.
  Timer.run(beginFrame);
  Timer.run(() {
    drawFrame();
    _endWarmUpFrame();
  });
}