EnhancedParser class

author:郑再红 email:1096877329@qq.com date:2026-04-29 17:20 describe: 增强的路由解析器 增强的路由解析器,支持:

  • 路径参数解析(/user/:id)
  • 查询参数解析(?key=value)
  • 路由别名(/home -> /)
  • 路由验证

使用示例:

final parser = EnhancedParser(
  enablePathParams: true,
  enableQueryParams: true,
  routeAliases: {'/home': '/'},
  patterns: [
    RoutePattern('/user/:id'),
    RoutePattern('/product/:category/:id'),
  ],
);

MaterialApp.router(
  routerDelegate: router,
  routeInformationParser: parser,
);
Inheritance

Constructors

EnhancedParser({bool enablePathParams = true, bool enableQueryParams = true, bool enableValidation = false, Map<String, String>? routeAliases, List<RoutePattern>? patterns, String? defaultRoute})
const

Properties

defaultRoute String?
默认路由(当路由不存在时跳转)
final
enablePathParams bool
是否启用路径参数解析
final
enableQueryParams bool
是否启用查询参数解析
final
enableValidation bool
是否启用路由验证
final
hashCode int
The hash code for this object.
no setterinherited
patterns List<RoutePattern>?
路由模式列表 用于匹配和解析路径参数
final
routeAliases Map<String, String>?
路由别名映射 例如:{'/home': '/', '/profile': '/user/profile'}
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
parseRouteInformation(RouteInformation routeInformation) Future<RouteInformation>
Converts the given route information into parsed data to pass to a RouterDelegate.
override
parseRouteInformationWithDependencies(RouteInformation routeInformation, BuildContext context) Future<RouteInformation>
Converts the given route information into parsed data to pass to a RouterDelegate.
inherited
restoreRouteInformation(RouteInformation configuration) RouteInformation?
Restore the route information from the given configuration.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited