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
Navigator expose more than just pop
. You can do things such as the following:
Navigator.pushNamedAndRemoveUntil(context, '/', (_) => false);
This will basically push a home and remove all the routes behind the new one
The good news is now we can use pushReplacementNamed
Navigator.pushReplacementNamed(context, '/');
(Channel master, v1.15.4-pre.97, I'm not sure the previous version can do that)
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