js
routes: <GoRoute>[
GoRoute(
name: 'family',
path: 'family/:fid',
builder: (BuildContext context, GoRouterState state) {
return FamilyScreen(
fid: state.pathParameters['fid']!,
asc: state.uri.queryParameters['sort'] == 'asc',
);
}
),
],
1 通过state.pathParameters 获取path上设置的参数,比如fid,也可以设置多个参数 比如path 设置为 family/:fid/:aid 就可以通过 state.pathParameters['fid'] 和 state.pathParameters['aid'] 分别获取path上设置的fid 跟 aid
2 跳转方式
js
context.go('/family/${entry.key}
或者
js
context.goNamed('family',
pathParameters: <String, String>{'fid': fid},
queryParameters: newQueries)