Navigator.pushNamed() method. Extract the arguments using the

ModalRoute.of() method or inside an

onGenerateRoute()
function provided to the

MaterialApp or

CupertinoApp
constructor.

This recipe demonstrates how to pass arguments to a named
route and read the arguments using ModalRoute.of()
and onGenerateRoute() using the following steps:

Define the arguments you need to pass.

Create a widget that extracts the arguments.

Register the widget in the routes table.

Navigate to the widget.

1. Define the arguments you need to pass

First, define the arguments you need to pass to the new route.
In this example, pass two pieces of data:
The title of the screen and a message.

To pass both pieces of data, create a class that stores this information.

2. Create a widget that extracts the arguments