restart static method

void restart(
  1. BuildContext context
)

Triggers a full rebuild of the nearest AppRestarter ancestor.

Finds the nearest AppRestarter ancestor in the widget tree and forces it to rebuild with a new UniqueKey, effectively restarting the subtree. If AppRestarter.onRestart is set, it is awaited before the rebuild.

If no AppRestarter ancestor is found, this call is a no-op. Ensure AppRestarter is placed above the widget calling this method (typically at the root, wrapping your MaterialApp).

Implementation

static void restart(BuildContext context) {
  context.findAncestorStateOfType<_AppRestarterState>()?.restart();
}