NavRouteGenerator class
Generates Route objects from route settings.
Wire this into MaterialApp.onGenerateRoute:
MaterialApp(
onGenerateRoute: NavRouteGenerator(
routes: Routes(), // your NavRoutes subclass
noRouteScreen: const NotFoundScreen(),
firstRoute: Routes.home,
builders: {
Routes.home: (_) => const HomeScreen(),
Routes.detail: (args) => DetailScreen(args: args as MyArgs),
},
).generateRoute,
)
Builder map
Each entry maps a route name to a builder that receives the original arguments (with transition metadata already stripped out):
Routes.profile: (args) {
final userId = args as String;
return ProfileScreen(userId: userId);
},
Constructors
Properties
-
builders
→ Map<
String, Widget Function(Object? arguments)> -
Maps route names → widget builders.
final
- firstRoute → String
-
The initial route of your app (used as fallback when name is null).
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- noRouteScreen → Widget
-
Shown when a route is not found in builders.
final
- routes → NavRoutes
-
Your NavRoutes subclass, used for optional validation logging.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
generateRoute(
RouteSettings settings) → Route - Pass this to MaterialApp.onGenerateRoute.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited