bringToFront static method

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

Bring the interleaved host to the front of the root overlay.

Implementation

static void bringToFront({BuildContext? context}) {
  final entry = _entry;
  if (entry == null) {
    // Ensure install if we have no entry yet.
    ensureInstalled(context: context);
    return;
  }

  final overlayState = resolveRootOverlay(context);
  if (overlayState == null) return;

  if (entry.mounted) {
    // Make promotion deterministic by re-inserting the same entry.
    // This avoids ambiguous behavior from rearrange() when only a subset
    // of overlay entries is provided.
    entry.remove();
    overlayState.insert(entry);
    return;
  }

  // Entry not mounted. If an install is queued, wait for that callback.
  if (_installScheduled) return;

  // Recover stale unmounted entry and reinstall.
  _entry = null;
  ensureInstalled(context: context);
}