Flutter Navigation pop to index 1

前端 未结 9 1334
梦毁少年i
梦毁少年i 2020-12-02 13:54

I am recursively adding routes to the navigator. There could be 20 views or more. Pop works as advertised, but I would like to pop to index 1 and remove all push history.

9条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 14:42

    Here Dashboard() is the screen name. So this will pop out all the screens and goto Dashboard() screen.

    Navigator.of(context).pushAndRemoveUntil(
                      MaterialPageRoute(builder: (c) => Dashboard()),
                      (route) => false)
    

提交回复
热议问题