You can write a function to pop every route, and push a new one when it's empty, something likw this:
void clearAndNavigate(String path) {
while (getGoRouter().canPop() == true) {
getGoRouter().pop();
}
getGoRouter().pushReplacement(path);
}
getGoRouter is an instance of GoRouter