onGenerateRoute property

RouteFactory? onGenerateRoute
final

The route generator callback used when the app is navigated to a named route.

If this returns null when building the routes to handle the specified initialRoute, then all the routes are discarded and Navigator.defaultRouteName is used instead (/). See initialRoute.

During normal app operation, the onGenerateRoute callback will only be applied to route names pushed by the application, and so should never return null.

This is used if routes does not contain the requested route.

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.

Implementation

final RouteFactory? onGenerateRoute;