requestBringToFront static method

void requestBringToFront({
  1. BuildContext? context,
})

Schedule a bring-to-front request on the next frame.

Implementation

static void requestBringToFront({BuildContext? context}) {
  if (context != null) {
    // Prefer the freshest context when provided.
    _pendingBringContext = context;
  }

  if (_bringToFrontScheduled) return;
  _bringToFrontScheduled = true;

  WidgetsBinding.instance.addPostFrameCallback((_) {
    // Reset scheduling flag and use the latest captured context.
    _bringToFrontScheduled = false;
    final pendingContext = _pendingBringContext;
    _pendingBringContext = null;
    bringToFront(context: pendingContext);
  });
}