I want to clear all previous routes in Getx. That's why I am using that function:
static Future<void> removeAllAndNavigate(
String nextScreen, {
bool Function(Route<dynamic>)? predicate,
dynamic arguments,
int? id,
Map<String, String>? parameters, }) async {
Get.offAllNamed(
nextScreen,
predicate: predicate,
arguments: arguments,
id: id,
parameters: parameters,
); }
But today I realised that, it remember the previous route name. Cause after navigating new screen, I called
print(Get.previousRoute);
and it show me previous route name. Where is the problem ?
Use the
Get.clearRouteTree();method to remove all the routes and clear the route tree from the navigation stack. It will completely reset the navigation history and remove all theroutespushed or replaced onto the stack.