Navigating to a New Screen and Passing Data Using Routes in Flutter

Anmol Gupta
4 min readJan 2, 2023

Master the art of navigating between screens and passing data using routes in Flutter

Flutter is a popular mobile development framework that allows developers to build natively compiled apps for multiple platforms using a single codebase. One of the core features of Flutter is the ability to navigate between screens and pass data between them.

In this tutorial, we’ll learn how to use the Navigator widget and routes to navigate to a new screen and pass data in Flutter. We'll start by defining a route for the new screen in the routes map of the MaterialApp widget. Then, we'll use the Navigator widget's pushNamed method to navigate to the new screen and pass any data we want to pass to the screen as the arguments parameter. Finally, we'll retrieve the data on the new screen using the ModalRoute.of(context).settings.arguments property.

1. Define the route for the new screen

The first step in navigating to a new screen and passing data in Flutter is to define a route for the new screen. A route is a mapping between a route name and a StatefulWidget that represents the screen.

To define a route, we’ll add it to the routes map of the MaterialApp widget. The key to the route should be a String that represents…

--

--