In this example, I will share how to navigate to the widget in Flutter. You can navigate to the ExtractArgumentsScreen when a user taps a button using Navigator.pushNamed(). Provide the arguments to the route via the arguments property. The ExtractArgumentsScreen extracts the title and message from these arguments.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | // A button that navigates to a named route. The named route // extracts the arguments by itself. RaisedButton( child: Text("Navigate to screen that extracts arguments"), onPressed: () { // When the user taps the button, navigate to a named route // and provide the arguments as an optional parameter. Navigator.pushNamed( context, ExtractArgumentsScreen.routeName, arguments: ScreenArguments( 'Extract Arguments Screen', 'This message is extracted in the build method.', ), ); }, ), |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.