handleBeginFrame method

  1. @override
void handleBeginFrame (Duration rawTimeStamp)
override

Called by the engine to prepare the framework to produce a new frame.

This function calls all the transient frame callbacks registered by scheduleFrameCallback. It then returns, any scheduled microtasks are run (e.g. handlers for any Futures resolved by transient frame callbacks), and handleDrawFrame is called to continue the frame.

If the given time stamp is null, the time stamp from the last frame is reused.

To have a banner shown at the start of every frame in debug mode, set debugPrintBeginFrameBanner to true. The banner will be printed to the console using debugPrint and will contain the frame number (which increments by one for each frame), and the time stamp of the frame. If the given time stamp was null, then the string "warm-up frame" is shown instead of the time stamp. This allows frames eagerly pushed by the framework to be distinguished from those requested by the engine in response to the "Vsync" signal from the operating system.

You can also show a banner at the end of every frame by setting debugPrintEndFrameBanner to true. This allows you to distinguish log statements printed during a frame from those printed between frames (e.g. in response to events or timers).

Implementation

@override
void handleBeginFrame(Duration rawTimeStamp) {
  assert(_doDrawThisFrame == null);
  if (_expectingFrame ||
      (framePolicy == LiveTestWidgetsFlutterBindingFramePolicy.fullyLive) ||
      (framePolicy == LiveTestWidgetsFlutterBindingFramePolicy.benchmark) ||
      (framePolicy == LiveTestWidgetsFlutterBindingFramePolicy.fadePointers && _viewNeedsPaint)) {
    _doDrawThisFrame = true;
    super.handleBeginFrame(rawTimeStamp);
  } else {
    _doDrawThisFrame = false;
  }
}