I am using PopNavigatorRouterDelegateMixin and RootBackButtonDispatcher and I would expect that the back button press would call the onPopPage method of the navigator built in the router delegate. Instead the back button pops the whole app.
This is the app code
GetMaterialApp(
navigatorKey: navigatorKey,
debugShowCheckedModeBanner: false,
home: Router(
routerDelegate: AppRouterDelegate(),
backButtonDispatcher: RootBackButtonDispatcher(),
),
and this is the RouterDelegate
class AppRouterDelegate extends RouterDelegate<AppRoutePath>
with ChangeNotifier, PopNavigatorRouterDelegateMixin<AppRoutePath> {
final GlobalKey<NavigatorState> navigatorKey;
AppRouterDelegate() : navigatorKey = GlobalKey<NavigatorState>();
@override
Widget build(BuildContext context) {
return Navigator(
pages: [
if (!context.watch<AppState>().loadingDone)
MaterialPage(child: LaunchWidget())
else
MaterialPage(child: AvailableMatches()),
if (context.watch<AppState>().selectedMatch != null)
MaterialPage(
key: ValueKey("MatchDetails"),
name: "MatchDetails",
child: MatchDetails(matchId: context.read<AppState>().selectedMatch)
)
],
onPopPage: (route, result) {
print("popping");
print(route.settings.name);
if (!route.didPop(result)) {
return false;
}
if (route.settings.name == "MatchDetails") {
context.read<AppState>().setSelectedMatch(null);
}
notifyListeners();
return true;
},
);
}
@override
Future<void> setNewRoutePath(AppRoutePath configuration) {}
}