Group Group Group Group Group Group Group Group Group

07 Routes and Navigation issue

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)

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 ( == FooderlichPages.profilePath) {

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.

@hongfeiyang thanks for the feedback and great catch!

In the onPressed callback, we update the tap state for profile screen. This will rebuilt the navigator list of pages.

If we however use navigator 1.0 API:


This will trigger the _handlePopPage() callback.