StaticRoute class
静态路由
所有静态路由页面都必须提供此静态实例
用于在MaterialApp.onGenerateRoute中注册,
StaticRoute实例应当使用同一名称route
。
页面导航时使用名称导航方法。
典型用法
class ExamplePage extends StatelessWidget {
ExamplePage(this.id, this.code);
final String id;
final int code;
/// 本页面路由器
static final route = StaticRoute(
name: 'ExamplePage',
builder: (RouteSettings settings) {
final arguments = settings.arguments as List;
return MaterialPageRoute(
settings: settings,
builder: (context) => ExamplePage(arguments[0], arguments[1]),
);
},
);
...
}
final routeTable = <StaticRoute>[
ExamplePage.route,
...
];
MaterialApp(
onGenerateRoute: routeTable.generateRoute,
);
Navigator.pushNamed(context, ExamplePage.route.name, arguments: ['test', 123]);
- Implementers
Constructors
- StaticRoute.new({required String name, required RouteFactory builder, OnStaticRouteExit? onExit})
-
const
Properties
- builder → RouteFactory
-
路由构建器
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- name → String
-
页面名称
final
- onExit → OnStaticRouteExit?
-
静态路由页面退出回调
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
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