endOfFrame property

Future<void> endOfFrame

Returns a Future that completes after the frame completes.

If this is called between frames, a frame is immediately scheduled if necessary. If this is called during a frame, the Future completes after the current frame.

If the device's screen is currently turned off, this may wait a very long time, since frames are not scheduled while the device's screen is turned off.


Future<void> get endOfFrame {
  if (_nextFrameCompleter == null) {
    if (schedulerPhase == SchedulerPhase.idle) {
    _nextFrameCompleter = Completer<void>();
    addPostFrameCallback((Duration timeStamp) {
      _nextFrameCompleter = null;
    }, debugLabel: 'SchedulerBinding.completeFrame');
  return _nextFrameCompleter!.future;