Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pushReplacementNamed is not working #26

Open
Jhalak1298 opened this issue Sep 18, 2020 · 3 comments
Open

pushReplacementNamed is not working #26

Jhalak1298 opened this issue Sep 18, 2020 · 3 comments

Comments

@Jhalak1298
Copy link

Navigator.pushReplacementNamed(context, '/home');
I used above code but it not woring ,but pushNamed is working .......

@felexkuria
Copy link

i used Navigator .push found that Navigator .pushReplacementNamed is very diffcult

@felexkuria
Copy link

felexkuria commented Feb 4, 2021

i used Navigator .push found that Navigator .pushReplacementNamed is very diffcult

Navigator.push( context, MaterialPageRoute( builder: (BuildContext context) => WorldTimeApp( flag: worldTime.flag, location: worldTime.location, time: worldTime.time, ), ), ); }

that is the code i used instead of Navigator.pushReplacementNamed but the trick is you have to replace

`
initialRoute: '/',
routes: {
'/': (context) => WorldTimeApp(

       ),
   'loading': (context) => Loading(),
   'location': (context) => ChooseLocatiion()
 },

with home:WorldTime(), and also create a consturctor in the home screen like soclass WorldTimeApp extends StatefulWidget {
WorldTimeApp(
{@required this.location, @required this.flag, @required this.time});
final String location;

final String flag;
final String time;inorder to acess the flag and location in home you will use widget.location Text(widget.time),`

@mostafijurrm
Copy link

Just simply add the below code:

Navigator.of(context).pushNamedAndRemoveUntil('/routeName', (route) => false);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants