Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i do push replacement using go router package in flutter [go router]

Tags:

flutter

dart

I am using the go router plugin for my flutter web application, but I didn't find any way to do push replacement in navigation.

not only push replacement, can we do any other type of navigation link

  • pushNamedAndRemoveUntil
  • popUntil because these navigation options must be needed in kind of any system!

What I tried

  • context.go(userStorage.redirectURL!);
  • GoRouter.of(context).go(PagesCollection.adminDashboard);

they only pushed the next page, not replacing

Note: I want this functionality in go router

like image 895
Chirag Mevada Avatar asked Feb 02 '26 05:02

Chirag Mevada


1 Answers

In the latest go_router, You can use

  1. pushReplacement - context.pushReplacement('/login');
void pushReplacement(
  String location,
  {Object? extra}
)
  1. pushReplacementNamed - context.pushReplacementName(Routes.login) (Routes is a class having defination of login)
void pushReplacementNamed(
  String name,
  {Map<String, String> params = const <String, String>{},
  Map<String, dynamic> queryParams = const <String, dynamic>{},
  Object? extra}
)
like image 164
krishnaacharyaa Avatar answered Feb 04 '26 23:02

krishnaacharyaa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!