How to reset the base route in my Flutter App - that is pop any routes and replace it with a new one using Navigator

后端 未结 3 1876
予麋鹿
予麋鹿 2021-02-07 13:00

New to Flutter to please forgive me if this is obvious, but I have read the documentation and tried a bunch of the Navigator options but none of them work as I would like. The

3条回答
  •  一整个雨季
    2021-02-07 13:43

    Try this code:

        Navigator.pushAndRemoveUntil(
                        context,
                        MaterialPageRoute(
                          builder: (BuildContext context) => YourInitialPage(),
                        ),
                        ModalRoute.withName('/'));
    

    If you don't want transition you can override or extend the MaterialPageRoute class

提交回复
热议问题