Navigation is one of the first things that feels easy in Flutter and one of the first things that gets messy in a real app. A two-screen demo needs a single push; a production app with tabs, a login flow, deep links and a web build needs a plan.
This article walks through the options in order of complexity, with the trade-offs you actually hit in practice: how many routes a screen stack typically grows to, what named routes cost you, and where declarative navigation starts paying for itself.
Key points
- Start with Navigator 1.0 and named routes; move to a declarative router when deep links or web URLs matter.
- Keep route construction in one place so adding an argument does not touch every call site.
- Use one nested navigator per tab and persist the selected tab index to survive process death.
- Pass IDs in web URLs and load objects from a repository, never through route arguments.
Navigator 1.0: The Imperative Baseline
The classic approach is a stack of routes managed by Navigator. You call Navigator.push with a MaterialPageRoute, and Navigator.pop to go back. It is simple, well documented, and still the right tool for modals, confirmation dialogs and short linear flows like onboarding or a checkout wizard.
The hidden cost is that every push is a state change made from inside a widget. Once a screen can be reached from five different places, the code that decides where to go next is scattered across the tree, and testing a full flow means driving the UI rather than asserting on a single object.
Keep route construction in one place even at this stage. A small set of static helper methods that return the right route for a screen saves you from rewriting a dozen call sites when a screen needs a new constructor argument.
- Use push/pop for modals, dialogs and one-off flows
- Wrap route creation in static helpers, not inline MaterialPageRoute calls
- Pass data through the route constructor, not through global state
- Call pop with a result and await it on the pushing side
Named Routes and Their Limits
Named routes move the route table into MaterialApp and let you navigate with strings. For a small app with under roughly ten screens this is convenient: deep-link handling becomes a single onGenerateRoute switch, and analytics can log a route name without touching each screen.
The limits appear quickly. Named routes cannot easily carry typed arguments without casting from a Map, and they do not compose well with nested navigators for tabs. Arguments passed as objects break the web URL story, since the browser only sees the path.
On web, a named-route setup typically maps to readable paths, but you still have to parse and validate the URL yourself. Once you need guards, redirects and query parameters, a router package becomes cheaper than the hand-rolled switch.
Navigator 2.0: Declarative Pages
Navigator 2.0 replaces the imperative stack with a list of pages you own. You keep the list in your state, derive it from app state, and rebuild. That makes the stack testable: given a logged-in user and a route, assert the resulting pages.
The price is boilerplate. A minimal implementation needs a RouterDelegate, a RouteInformationParser and often a BackButtonDispatcher, which is easily 150 to 250 lines before the app does anything useful. For simple apps that overhead is not repaid.
Where it earns its keep is deep linking, web URLs and flows where the destination depends on several pieces of state, such as an auth token plus a selected project. The pages list becomes a pure function of state, which is far easier to reason about than scattered pushes.
Passing Data Between Screens
For a single value, a constructor argument plus a typed result from pop is the cleanest thing you can do. Navigator.pop(context, result) and awaiting the push keeps the contract local to the two screens and needs no shared state.
When several screens in a flow need the same object, an inherited widget or a state management solution is better than threading arguments through five constructors. The rule of thumb: pass explicitly while the chain is one hop, switch to shared state at two or more.
Avoid passing large objects through route arguments on web. Route arguments are not serialised into the URL, so a refresh loses them. Keep identifiers in the path or query, and load the object from a repository on the destination screen.
- One hop: constructor argument
- Returning a value: await Navigator.push, pop with result
- Multi-screen flow: shared state or inherited widget
- Web: keep IDs in the URL, load data on arrival
| Approach | Typical screen count | Deep links | Web URLs | Setup effort |
|---|---|---|---|---|
| Navigator 1.0 (push/pop) | 1–10 | Manual | Poor | Very low |
| Named routes | 5–20 | Via onGenerateRoute | Workable | Low |
| Navigator 2.0 (Router API) | 15+ | Native | Good | High |
| Router package | 10+ | Native with guards | Good | Medium |
| Nested navigators per tab | Any with tabs | Per tab | Depends on router | Medium |
Nested Navigators, Tabs and State
Bottom-tab apps often need a separate stack per tab so that switching tabs preserves each tab's history. That means one Navigator per tab, each with its own key, plus a way to handle the system back button so it pops the active tab rather than exiting the app.
A common pattern is an IndexedStack holding the tab navigators with a WillPopScope or PopScope wrapper that decides whether to pop the inner navigator or the outer one. The subtle bug is restoring the wrong tab after process death, so persist the selected index alongside the stack.
Configuration changes are the other trap. If a screen rebuilds on rotation and re-creates state, the back stack can look intact while the screen behind it is empty. Keeping state in a view model rather than the widget solves both navigation and rebuild problems, as covered in Handling Configuration Changes in Kotlin Without Losing State.
When to Add a Router Package
A router package is worth adding when you need typed routes with path and query parameters, redirect guards for authentication, and the same route table across mobile and web. It replaces the hand-written RouteInformationParser and most of the delegate boilerplate.
The migration cost is real but bounded: typically a day or two for a mid-sized app with 15 to 30 screens. The bigger cost is architectural — routes become first-class objects, so decide early whether route parsing lives in the presentation layer or is injected from a repository.
If you are still at five screens, stay on Navigator 1.0 with named routes and revisit when you add a second entry point or a web build. The same judgement applies to client layers: pick the simpler option until a concrete need appears, as in Retrofit vs Ktor Client: Small App Comparison Guide.
Editor and Flutter contributor. Writes practical Flutter tutorials focused on widgets, layout and animation. Enjoys breaking large UI problems into small, testable pieces and explaining them clearly to beginners.




