zoukankan      html  css  js  c++  java
  • flutter 路由 fluro

    代码:

    1.
    import 'package:fluro/fluro.dart';
    import 'package:flutter/material.dart';
    import 'router_handle.dart';

    class MainRouter {
    static String root = '/';
    static String goodDetail = '/goodsDetail';
    static void configureRoutes(Router router){
    router.notFoundHandler = new Handler(
    handlerFunc: (BuildContext context,Map<String,List<String>> params){
    print('Not Found Router');
    }
    );
    router.define(goodDetail, handler: goodsHandle);//商品详情路由


    }
    }
     
     
    2.
    Handler goodsHandle = Handler(
    handlerFunc: (BuildContext context,Map<String,List<String>> params){
    String goodsId = params['id'].first;
    print('detail->route goodsid : ${goodsId}');


    return GoodDetail(goodsId);
    }

    );
     
    3.
    class Application {
    static Router router;
    }
    4.
    final router = new Router();
    MainRouter.configureRoutes(router);
    Application.router = router;
    return Container(
    child: MaterialApp(
    title: '网商项目',
    onGenerateRoute: Application.router.generator,
    debugShowCheckedModeBanner: false,//去掉debug样式
    theme: ThemeData(
    primaryColor: Colors.pink//主题样式颜色
    ),
    home: IndexPage(),
    ),
    );
    5.
    onTap: (){
    Application.router.navigateTo(context, '/goodsDetail?id=${val['goodsId']}');
    },
    总结:

    flutter 路由 fluro

    下载 fluro: ^1.4.0

    单个路由的实例

    Handle xxxx = Handle(

    handlerFunc:(BuildContext context,Map<String,List<String>> prarams){

    print(‘调用XX路由实例’)

    return 返回某个页面,也可省略

    }

    )

    Xxx 是实例变量

    使用主Route 统一分发

    Class YYY{

    static String root = ‘/’;

    static String  xxString  = ‘/xxx’ //上面实例相关的实例变量地址

    static void  yyconfigurationRoutes(Router router){

    router.notFoundHandle = new Handle(//未识别到的路由跳转

    handleFunc:(BuildContext context,Map<String,List<String>> params){

    }

    )

    router.define(xxString,handle:xxxx)

    }

    }

    yyconfigurationRoutes YYY下的静态实例方法

    加载静态管理

    class Application {

        static Router router;

    }

    main函数初始化

    final yy = New Router();//yy Router变量

    YYY.yyconfigurationRoutes(yy);

    Application.router = router;

    在main函数中的Container使用

    onGenerateRoute:Application.router.generator

    在某个跳转中使用

    onTap: (){

                  Application.router.navigateTo(context, '/goodsDetail?zzzzz'); goodsDetail就是xxString,zzzz是其他

                },

  • 相关阅读:
    姐姐的vue(1)
    LeetCode 64. Minimum Path Sum 20170515
    LeetCode 56. 56. Merge Intervals 20170508
    LeetCode 26. Remove Duplicates from Sorted Array
    LeetCode 24. Swap Nodes in Pairs 20170424
    LeetCode 19. Remove Nth Node From End of List 20170417
    LeetCode No.9 Palindrome Number 20170410
    LeetCode No.8. String to Integer (atoi) 2017/4/10(补上一周)
    LeetCode No.7 Reverse Integer 2017/3/27
    LeetCode No.4 Median of Two Sorted Arrays 20170319
  • 原文地址:https://www.cnblogs.com/pp-pping/p/12305277.html
Copyright © 2011-2022 走看看