You can navigate to a new screen by creating a new route and pushing it to the Navigator.
However, if you need to navigate to the same screen in many parts of your app, this approach can result in code duplication. The solution is to define a named route, and use the named route for navigation.
To work with named routes, use the Navigator.pushNamed() function. This example replicates the functionality from the original recipe, demonstrating how to use named routes using the following steps:
Create two screens.
Define the routes.
Navigate to the second screen using Navigator.pushNamed().
Return to the first screen using Navigator.pop().