Flutter Learning (II) -FlutterGo learning

Directory
Flutter learning (a)
Flutter Learning (II) -FlutterGo learning

FlutterGo Ali auction for the front-end team in today's cross-platform mobile solutions is the fire APP project launched instance, Flutter for beginners to learn to master this project is extremely useful.
github Address: https://github.com/alibaba/flutter-go

Directory Structure

fluro

Flutter itself provides the routing mechanism for individual small-scale projects, completely sufficient. But if you want to make enterprise development, the import documents might become bloated. And then Flutter's inception, it has enterprise-class routing scheme fluro.
github Address: https://github.com/theyakka/fluro
here to write a more detailed article: Flutter routing _fluro introduced to configure and use
then Flutter development documentation demo of continued learning fluro.
In mai.dart in the top right corner, will open has a collection of names, used flutter original demo that comes with routing to achieve, and now I use fluro to achieve.
Directory structure is as follows:
Here Insert Picture Description
1, first write the favorites list, the interface is very simple, put the name of the show you pass over (suggestion_page.dart):

import 'package:flutter/material.dart';

class SuggestionPage extends StatefulWidget {
  String suggestions;

  SuggestionPage(String suggestions) {
    this.suggestions = suggestions;
  }

  @override
  State<StatefulWidget> createState() {
    return SuggestionWidget();
  }

}

class SuggestionWidget extends State<SuggestionPage> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: new Center(
        child: Text(widget.suggestions),
      ),
    );
  }

}

2, the process jumps router handle (router_handle.dart):

import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/views/suggestion_page.dart';

var suggestionHandle = new Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> params) {
      var suggestions = params['suggestions'].first; // router参数
      return new SuggestionPage(suggestions); // 收藏界面
    }
);

3, define the routing file (routers.dart):

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

class Routers {
  static String root = '/'; // 根目录
  static String suggestion = '/suggestion'; // 收藏界面

  static void configRouters(Router router) {
    router.notFoundHandler = new Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
        print('ERROR====>ROUTE WAS NOT FONUND!!!');
      }
    );
    
    router.define(suggestion, handler: suggestionHandle);// 收藏界面
  }
}

4, the global management router file (application.dart), so do not always go to new router:

import 'package:fluro/fluro.dart';

class Application {
  static Router router;
}

5, initialization routing main.dart in:

class MyApp extends StatelessWidget {

  MyApp() {
    final router = Router();
    Routers.configRouters(router);
    Application.router = router;
  }
  // ...........
  //调用路由跳转
Application.router.navigateTo(context, '${Routers.suggestion}?suggestions=${strJson}');
}

It seems only parameter of type String? ? ?

Published 216 original articles · won praise 91 · Views 250,000 +

Guess you like

Origin blog.csdn.net/yu75567218/article/details/104008704