go_router_back_handler library
A robust back button handler for GoRouter that works on all routes.
This package solves the PopScope limitation in GoRouter v13+ by using native Android MethodChannel integration to intercept back button presses at the platform level.
Features
- Works on ALL routes including root routes
- Smart route detection and parent finding
- Customizable exit confirmation dialog
- Sequential flow support (registration/wizard flows)
- Dynamic route handling (parameterized routes)
- Zero configuration with sensible defaults
Quick Start
void initState() {
super.initState();
GoRouterBackHandler.initialize(
navigatorKey: rootNavigatorKey,
routeHierarchy: {
'/profile': '/home',
'/settings': '/home',
},
);
}
Classes
- BackHandlerConfig
- Configuration for GoRouterBackHandler
- DefaultExitDialog
- Default exit confirmation dialog with modern design
- GoRouterBackHandler
- Main service that handles back button via MethodChannel from native Android