navigatePushReplacement method
void
navigatePushReplacement({
Implementation
void navigatePushReplacement({required BuildContext context, required Widget pageToNavigate, required String routeName, Function()? onNavigateComplete}) {
// Navigate to the new route (simulated navigation)
currentRoute = routeName;
debugPrint("Navigating to $routeName");
// Push the current route to the history before navigating
if (currentRoute != null) {
debugPrint("Adding the current route");
routeHistory.removeLast();
routeHistory.add(currentRoute!);
} else {
debugPrint("current route is null not adding the history");
}
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (context) => pageToNavigate,
),
).then((value) => onNavigateComplete?.call());
}