initialRoute property

String? initialRoute

The name of the first route to show, if a Navigator is built.

Defaults to dart:ui.PlatformDispatcher.defaultRouteName, which may be overridden by the code that launched the application.

If the route name starts with a slash, then it is treated as a "deep link", and before this route is pushed, the routes leading to this one are pushed also. For example, if the route was /a/b/c, then the app would start with the four routes /, /a, /a/b, and /a/b/c loaded, in that order. Even if the route was just /a, the app would start with / and /a loaded. You can use the onGenerateInitialRoutes property to override this behavior.

Intermediate routes aren't required to exist. In the example above, /a and /a/b could be skipped if they have no matching route. But /a/b/c is required to have a route, else initialRoute is ignored and Navigator.defaultRouteName is used instead (/). This can happen if the app is started with an intent that specifies a non-existent route.

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

See also:


final String? initialRoute;