Flutter App: Navigating to Blank Page After Tapping Back Button from Push Notification

120 Views Asked by At

i create an app that have push notification in background, when the user tap the notification bubble, it can navigate smoothly to the page. but the problem is when the user tap the back button in the android phone, it will go to the blank page enter image description here

here is my code

return await CustomDialog.show(
        context,
        title: "Quit App",
        description: "Are you sure you want to quit the app?",
        btnCancelText: "No",
        btnOkText: "Yes",
        btnCancelOnPress: () => Navigator.of(context).pop(),
        btnOkOnPress: () {
         
          Navigator.of(context).pop(true);
        },
        icon: Iconsax.info_circle,
        dialogType: DialogType.success,
      )

i try the SystemNavigator.pop(); but still not working

2

There are 2 best solutions below

2
On

That is because there seems to be only one page available in your stack. This could be solved by using the correct Navigator.

Please add more code to where the routing to the Notification actually occurs.

0
On

It's occurs because when you navigate from background you direct load the specific page. It's not the correct way to load the page, you should load your splash/initial page first or your landing page then load your specific page.It will solve your problem. Try to focus on your navigation load.