finalizeBridges method

void finalizeBridges()

Runs every extension callback registered via registerExtensions in registration order, then marks the runner as finalized.

execute*/executeBundle* invoke this implicitly on first run if it has not been called already, so embedders don't have to remember to call it. Calling it explicitly first is supported and preferred when an embedder needs deterministic timing (e.g. a constructor of a Flutter helper that touches bridges before the first script runs).

Idempotent: repeat calls return without re-running any callback — the contract is "run once, then frozen". After this call returns, registerExtensions throws StateError.

Implementation

void finalizeBridges() {
  if (_bridgesFinalized) return;
  _bridgesFinalized = true;
  for (final entry in _extensionCallbacks.entries) {
    Logger.debug(
      '[D4rtRunner.finalizeBridges] Running extensions for "${entry.key}"',
    );
    entry.value();
  }
}