命名路由传参

import 'package:flutter/material.dart';
import 'package:flutter_apptwo/namedrouteargument/pages/Form.dart';
import 'package:flutter_apptwo/namedrouteargument/pages/Product.dart';
import 'package:flutter_apptwo/namedrouteargument/pages/ProductInfo.dart';
import 'package:flutter_apptwo/namedrouteargument/pages/Search.dart';
import 'package:flutter_apptwo/namedrouteargument/pages/Tabs.dart';

final routes={
  '/':(context)=>Tabs(),
  '/form':(context)=>FormPage(),
  '/product':(context)=>ProductPage(),
  '/search':(context,{arguments})=>SearchPage(arguments:arguments,),
  '/productinfo':(context,{arguments})=>ProductInfoPage(arguments: arguments,),



};



var onGenerateRoute=(RouteSettings settings){
  final String name=settings.name;
  final Function pageContentBuilder=routes[name];
  if(pageContentBuilder!=null){
    if(settings.arguments!=null){
      final Route route=MaterialPageRoute(
        builder: (context)=>
            pageContentBuilder(context,arguments:settings.arguments));
      return route;



    }else{
      final Route route=MaterialPageRoute(
        builder: (context)=>
            pageContentBuilder(context));
      return route;
    }
  }


};

flutter命名路由传参

上一篇:Flutter 路由管理


下一篇:Rabbitmq之死信队列