• flutter-路由


    1.新建1个页面 details_page.dart

    2.引入  fluro: "^1.6.3"

    3.在lib文件夹下新建文件夹router,然后新建router_handler.dart

    import 'package:flutter/material.dart';
    import 'package:fluro/fluro.dart';
    import '../pages/details_page.dart';
    
    var detailsHandler=Handler(
      handlerFunc: (BuildContext context,Map<String, dynamic> params){
        String goodsId=params['id'].first;
        return DetailsPage(goodsId);
      }
    );

    4.新建文件routes.dart

    import 'package:flutter/material.dart';
    import 'package:fluro/fluro.dart';
    import './router_handler.dart';
    
    class Routes{
      static String root='/';
      static String detailsPage='/detail';
      static void configureRoutes(Router router){
        router.notFoundHandler=new Handler(//找不到路由
          handlerFunc:(BuildContext context,Map<String, dynamic> params){
            print('Error===>ROUTE WAS NOT FOUND!!!!');
          }
        );
        router.define(detailsPage, handler: detailsHandler);//配置地址路由
      }
    }

    5.新建application.dart 方便以后不引入 不用new了

    import 'package:fluro/fluro.dart';
    
    class Application{
      static Router router;
    }

    6.main.dart

    import 'package:fluro/fluro.dart';

    import './router/application.dart';
    import './router/routes.dart';
    //在build中引入
    final router=Router();
    Routes.configureRoutes(router);
    Application.router=router;

     7.使用

    import '../router/application.dart';
  • 相关阅读:
    单个对象的内存管理分析
    在eclipse中引入jquery.js文件报错的解决方案
    ajax复习
    jquery介绍
    ajax调试小技巧
    ajax实现聊天室功能
    ajax(2)
    ajax经典案例--省市联动
    ajax技术返回json如何处理
    ajax如何处理返回的数据格式是xml的情况
  • 原文地址:https://www.cnblogs.com/lxz-blogs/p/13305484.html
Copyright © 2020-2023  润新知