I was able to accomplish this with the following code:
Navigator.of(context)
.pushNamedAndRemoveUntil('/login', (Route<dynamic> route) => false);
The secret here is using a RoutePredicate that always returns false (Route<dynamic> route) => false
. In this situation it removes all of the routes except for the new /login
route I pushed.
Related Contents:
- How to change status bar color in Flutter?
- What’s the difference between async and async* in Dart?
- How can I hide letter counter from bottom of TextField in Flutter
- What is the relation between stateful and stateless widgets in Flutter?
- how to use local flutter package in another flutter application?
- Converting timestamp
- Dart Multiple Constructors
- flutter – correct way to create a box that starts at minHeight, grows to maxHeight
- Check value in array exists Flutter dart
- Flutter – Read text file from assets
- How do I check if the Flutter application is in the foreground or not?
- Flutter Navigator.pop(context) returning a black screen
- Flutter – ‘initialValue == null || controller == null’: is not true. error
- How to run code after showDialog is dismissed in Flutter?
- `vsync` property in TabController constructor
- Display SnackBar in Flutter
- Horizontally scrollable cards with Snap effect in flutter
- Full width DropdownButton with adjust dropdown arrow icon in Flutter
- Flutter: Update Widgets On Resume?
- Flutter – How to hide/remove title of BottomNavigationBarItem
- How do I stack widgets overlapping each other in flutter
- How to pass data from child widget to its parent
- Displaying notification badge on BottomNavigationBar’s Icon
- How do I call async property in Widget build method
- How do I only apply padding to the text in a TextField in Flutter?
- Flutter onClosing callback for showModalBottomSheet
- No Directionality widget found
- Constructor Optional Params
- How do I pass non-string data to a named route in Flutter?
- How to make HTTP POST request with url encoded body in flutter?
- Flutter – FloatingActionButton in the center
- How to get the last n-characters in a string in Dart?
- Flutter – How does it work behind the scenes?
- How to customize a date picker
- How to remove extra padding around AppBar leading icon in Flutter
- Flutter : Where is the title of Material App used?
- How can I read (from disk) and resize an image, in Flutter/Dart
- How to convert to double
- Flutter setState to another class?
- Flutter TabBar Without AppBar
- how to create a row of scrollable text boxes or widgets in flutter inside a ListView?
- Flutter persistent navigation bar with named routes?
- How to show fullscreen image in flutter
- How to load images with image.file
- Flutter listview with Map instead of List
- Get the name of a Dart class as a Type or String
- Flutter: adjust height of PageView/Horizontal ListView based on current child
- Flutter – Why is child widget’s initState() is not called on every rebuild of Parent widget?
- flutter ListView scroll to index not available
- Good or Bad: Declaring main method async in Dart / Flutter