go_router 页面跳转 参数传递

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)
相关推荐
末代iOS程序员华仔4 小时前
iOS 5.6 条例解决方法
flutter·ios·swift
末代iOS程序员华仔9 小时前
Guideline 5.6 - Developer Code of Conduct
flutter·ios·swift
恋猫de小郭11 小时前
聊个比较有意思的 Flutter Web 问题
android·前端·flutter
2501_9159184111 小时前
Flutter项目配置iOS混淆的详细步骤与工具推荐
android·flutter·ios·小程序·uni-app·cocoa·iphone
天空之城--11 小时前
过去一周Android行业动态:编码技术与综合趋势精选
android·flutter·性能优化·kotlin·android jetpack
Flutter OH1 天前
Flutter OH平台 DFX 问题定位导航
flutter
恋猫de小郭1 天前
AI 时代,也许你的 Flutter 需要一套 Dartastic OpenTelemetry 监控
android·前端·flutter
等....1 天前
Flutter创建
flutter
Privasa-隐私实验室1 天前
跨端技术选型|Flutter搭建隐私加密App,安卓与iOS双端差异适配实战
android·笔记·安全·flutter·ios·隐私安全·aes-256
Flutter OH2 天前
Flutter OH 外接纹理问题定位指南
flutter