📚 Encyclopedia

Flutter & Mobile · updated 2026-10-13

Android back button in Flutter with go_router (and Android 16 predictive back)

flutterandroidback-buttonpopscopego_routerpredictive-backandroid-16

The Android back button is the most regression-prone part of the TLDR app: it broke several times, and each time the symptom was the worst one, the app closing on the first tap. The working setup is specific, and Android 16 made predictive back mandatory in a way Flutter's ShellRoute did not handle as of go_router 17.

Desired behavior

Back walks the app's own navigation history, then lands on the home tab (/posts), then shows "press back again to exit", and only exits on a second press within 2 seconds.

The working configuration

Android 16 finding (March 2026)

PredictiveBackPageTransitionsBuilder with enableOnBackInvokedCallback="true" exits the app immediately on Android 16 (API 36), even with go_router 17 and PopScope(canPop: false) at the root. PopScope on the root/ShellRoute does not propagate canPop to the system where predictive back is mandatory. Upgrading go_router 14 to 17 did fix an older PopScope bug in branch routes (no breaking changes, but run flutter clean after the upgrade or stale build caches throw null-subtype errors). Do not re-enable predictive back until ShellRoute support is fixed upstream.

Process rule

Any change to the router, the app shell, the post detail screen, page transitions or the manifest can break back handling. Verify on two devices: an older Android (here a Pixel 2 XL, Android 11) and Android 16, before committing. Reduced-motion settings change transitions too (with the animator duration scale off, swipe navigation collapses to a plain slide; that is intended).

See also

Linked from

Sources: tldr memory (feedback_back_button, completed-work, bug_ai_new_back_nav, MEMORY.md)