Skip to content Skip to sidebar Skip to footer

Why Does It Not Work When I Use Pushnamedreplacement Instead Of Pushreplacement?

I tried using named routes but it doesn't seem it work giving me an error 'could not find a generator for route ('/homepage',null) for _MaterialAppState.I couldn't understand the w

Solution 1:

You should use:

Navigator.of(context).pushReplacementNamed('/homepage');

Look at the documentation for more details.

EDIT: Use only 1 material app. Using two material apps (in main.dart and in Auth.dart) leads flutter to search the route in the closest MatertialApp (Auth.dart) and the route definition is in the highest instace (main.dart). You should remove the MaterialApp from Auth.dart

Post a Comment for "Why Does It Not Work When I Use Pushnamedreplacement Instead Of Pushreplacement?"