Learn about Go_router how to remove all the previous routes. Here we will learn how to do it using navigator 2.0
Go_router does not provide a direct api to do it. Currently Go router provides the below api
Since go router does not provide direct api, we will below code format to do it
Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(builder: (context) =>
LoginScreen()), (Route<dynamic> route) => false);
Instead of calling context.go() or context.push() we will call above api.
Replace LoginScreen() with any of your screen.