Fluro_Plus项目简介
Fluro_Plus对Fluro的传参进行来包装,通过传递和接收Bundle来方便使用,目前在初学阶段,欢迎指点
使用说明
引入依赖
构建项目路由
| |
| |
| |
| |
| |
| |
| |
| class Routers extends FluroPlusPageRouters { |
| static String home = "/home"; |
| static String one_page = "/one_page"; |
| static String two_page = "/two_page"; |
| |
| @override |
| List<FluroPlusPageRouter> generatorRoutes() { |
| return [ |
| FluroPlusPageRouter( |
| path: home, |
| widgetFunc: (Bundle bundle) { |
| return HomePage(); |
| }), |
| FluroPlusPageRouter( |
| path: one_page, |
| widgetFunc: (Bundle bundle) { |
| return NewOnePage( |
| bundle: bundle, |
| ); |
| }) |
| ]; |
| } |
| } |
初始化路由
| MyApp() { |
| FluroPlusApp.setupRoutes(Routers()); |
| } |
| |
| MaterialApp( |
| onGenerateRoute: FluroPlusApp.router.generator, |
| ); |
页面接收
| class NewOnePage extends StatefulWidget { |
| |
| |
| final Bundle bundle; |
| |
| const NewOnePage({Key key, this.bundle}) : super(key: key); |
| |
| @override |
| _NewOnePageState createState() => _NewOnePageState(); |
| } |
| |
| class _NewOnePageState extends State<NewOnePage> { |
| @override |
| Widget build(BuildContext context) { |
| print('bundle >>>>::: ${widget.bundle.runtimeType}'); |
| return Scaffold( |
| appBar: AppBar( |
| title: Text("演示NewOnePage页"), |
| ), |
| body: Container( |
| child: Center( |
| child: Column( |
| children: <Widget>[ |
| Text('name ${widget.bundle.getString('name')}'), |
| Text('yname ${widget.bundle.getString('yname')}'), |
| Text('desc ${widget.bundle.getString('desc')}'), |
| Text('age ${widget.bundle.getInt('age')}'), |
| Text('sex ${widget.bundle.getBool('sex')}'), |
| Text('language ${widget.bundle.getList('language')?.first}'), |
| Text('height ${widget.bundle.getDouble('height')}'), |
| ], |
| ), |
| ), |
| ), |
| ); |
| } |
| } |
API使用
| /// 简单跳转 |
| RaisedButton( |
| child: Text('简单跳转'), |
| onPressed: () { |
| FluroPlusNavigate.goto(context, Routers.one_page); |
| }), |
| |
| /// 简单跳转+转场动画 |
| RaisedButton( |
| child: Text('简单跳转+转场动画'), |
| onPressed: () { |
| FluroPlusNavigate.goto(context, Routers.one_page, |
| transitionType: TransitionType.inFromBottom); |
| }), |
| |
| /// 简单跳转+跳转后销毁当前页面 |
| RaisedButton( |
| child: Text('简单跳转+跳转后销毁当前页面'), |
| onPressed: () { |
| FluroPlusNavigate.goto(context, Routers.one_page, |
| replace: true); |
| }), |
| |
| /// 简单跳转+携带参数 |
| RaisedButton( |
| child: Text('简单跳转+携带参数'), |
| onPressed: () { |
| Bundle bundle = Bundle() |
| ..putString('name', name, isComponent: true) |
| ..putString('yname', yname) |
| ..putString('desc', desc, isComponent: true) |
| ..putBool('sex', sex) |
| ..putInt('age', age) |
| ..putList('language', language) |
| ..putDouble('height', height); |
| FluroPlusNavigate.goto(context, Routers.one_page, |
| bundle: bundle); |
| }), |
| |
| /// 简单跳转+携带参数+接收返回结果 |
| RaisedButton( |
| child: Text('简单跳转+携带参数+接收返回结果'), |
| onPressed: () { |
| Bundle bundle = Bundle() |
| ..putString('name', name, isComponent: true) |
| ..putString('yname', yname); |
| FluroPlusNavigate.gotoWithResult(context, Routers.one_page, |
| bundle: bundle, function: (result) { |
| print('result ::: ${result}'); |
| }); |
| }), |
Fluro_Plus源码地址,部分代码来自网络搜索来的案例,并注释了来源,如有未标明了请联系我一下。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)