How to check which the current Route is?

前端 未结 11 748
栀梦
栀梦 2021-02-03 17:49

I want to navigate to different Routes using a Drawer, though I do not want to open a new instance of a Route each time I tap on it if I am already on that Route, rather I would

11条回答
  •  萌比男神i
    2021-02-03 18:16

    This is my solution.

    void redirect(screen){
      Navigator.popUntil(context, (route) {
        if ( route.settings.name != screen) {
          Navigator.pushNamed(context, screen);
        }
        return true;
      });
    }
    

提交回复
热议问题