How can we use pushReplacment using go-router package
I tried this but didn't work
context.pushReplacement("register");
To use the Navigator API with named routes (pushNamed, pushReplacementNamed, or pushNamedAndRemoveUntil), the Navigator must be provided with an onGenerateRoute handler.
Here is my setup
final GoRouter _router = GoRouter(
debugLogDiagnostics: true,
routes: <RouteBase>[
GoRoute(
path: '/',
builder: (BuildContext context, GoRouterState state) {
return const MainPage();
},
routes: <RouteBase>[
GoRoute(
path: 'login',
builder: (BuildContext context, GoRouterState state) {
return const Login();
},
),
GoRoute(
path: 'register',
builder: (BuildContext context, GoRouterState state) {
return const SignUp();
},
),
],
),
],
);
I want to navigate between routes in flutter.