routes property

Map<String, WidgetBuilder>? routes
final

The application's top-level routing table.

When a named route is pushed with Navigator.pushNamed, the route name is looked up in this map. If the name is present, the associated widgets.WidgetBuilder is used to construct a PageRoute specified by pageRouteBuilder to perform an appropriate transition, including Hero animations, to the new route.

If the app only has one page, then you can specify it using home instead.

If home is specified, then it implies an entry in this table for the Navigator.defaultRouteName route (/), and it is an error to redundantly provide such a route in the routes table.

If a route is requested that is not specified in this table (or by home), then the onGenerateRoute callback is called to build the page instead.

The Navigator is only built if routes are provided (either via home, routes, onGenerateRoute, or onUnknownRoute); if they are not, builder must not be null.

If the routes map is not empty, the pageRouteBuilder property must be set so that the default route handler will know what kind of PageRoutes to build.

Implementation

final Map<String, WidgetBuilder>? routes;