[go_router] Fix Block.then() re-entrancy when triggered by refreshListenable by davidmigloz · Pull Request #11136 · flutter/packages

@davidmigloz

…tenable

`Block.then(() => router.go(...))` callbacks silently lose their
navigation when triggered by `refreshListenable`. The `router.go()`
inside the callback runs synchronously during `handleTopOnEnter`,
triggering a re-entrant `_processRouteInformation` whose result is
dropped due to transaction token churn in Flutter's Router.

Fix: wrap the `then` callback in `scheduleMicrotask()` so it runs
after the current parse completes and Flutter's Router has committed
the result. This is consistent with the `then` documentation which
states the callback is "executed after the decision is committed".

Adds 5 regression tests covering Block.then + refreshListenable,
goNamed variant, rapid emissions, Allow.then, and error propagation.

Fixes flutter/flutter#183012