Hi @vincentngo,
In chapter 7 routes and navigation, it seems that clicking the ‘cross’ button on profile page to dismiss the profile page does not fire any ‘pop’ event. Below are the code related to this issue:
line 29 - 38, lib/screens/profile_screen.dart
, project final
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: const Icon(Icons.close),
onPressed: () {
Provider.of<ProfileManager>(context, listen: false)
.tapOnProfile(false);
},
),
),
It seems that leading
here does not fully override the default back button, therefore when you click on it, it does not fire any system level pop event, hence it will not trigger _handlePopPage()
in ‘app_router.dart’, and hence line 99 - 101 in lib/navigation/app_router.dart
will never get executed:
if (route.settings.name == FooderlichPages.profilePath) {
profileManager.tapOnProfile(false);
}
If you instead use the normal system default back button in the profile page, this will work as intended, but you don’t get the cross icon, you only get the default left chevron icon instead.