Flutter - Navigate to a new screen, and clear all the previous screens

后端 未结 3 1820
旧时难觅i
旧时难觅i 2020-12-15 05:01

I used Navigator.push up to 6 screens to get to the payment page. After Payment, I want to push to the \"Payment Successful\" page then remove all the previous

3条回答
  •  情书的邮戳
    2020-12-15 05:42

    I would Suggest use WillPopScope in your Payment successful page and onWillPop method write following snippet of code:

     return WillPopScope(
          onWillPop: (){
            Navigator.of(context)
                .pushNamedAndRemoveUntil('/Home', (Route route) => false);
          },
          child: Scaffold()
    };
    

提交回复
热议问题