In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to use the routing framework Fluro, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
In the process of Flutter application development, in addition to using the routing officially provided by Flutter, some third-party routing frameworks can also be used to achieve page management and navigation, such as Fluro, Frouter and so on.
Fluro as an excellent Flutter enterprise routing framework, the use of Fluro is a little more complex than the official routing framework, but it is very suitable for medium and large projects. Because it has the advantages of hierarchical, organized, easy to expand and easy to manage routing as a whole.
So how do we use this excellent framework? Follow me
There are also BATJ, byte jump interview topics, algorithm topics, high-end technology topics, mixed development topics, java interview topics, Android,Java tips, to performance optimization. Thread .View.OpenCV.NDK, etc. have been uploaded to my GitHub
My GitHub learning address: https://github.com/Meng997998/AndroidJX click star to learn together
You need to add Fluro dependencies to the pubspec.yaml file before using Fluro, as shown below.
Dependencies: fluro: "^ 1.5.1"
If you cannot add Fluro dependencies in the above way, you can also add Fluro dependencies in the same way as git, as shown below.
Dependencies: fluro: git: git://github.com/theyakka/fluro.git
After successfully adding Fluro library dependencies, you can use Fluro for application routing management and navigation development. In order to facilitate the unified management of routes, it is necessary to create a new route map file to manage each route. As shown below, is the sample code for the routing profile route_handles.dart.
Import 'package:fluro/fluro.dart';import' package:flutter/material.dart';import 'package:flutter_demo/page_a.dart';import' package:flutter_demo/page_b.dart';import 'package:flutter_demo/page_empty.dart';// empty page var emptyHandler = new Handler (handlerFunc: (BuildContext context, Map params) {return PageEmpty ();}) / / A page var aHandler = new Handler (handlerFunc: (BuildContext context, Map params) {return PageA ();}); / / B page var bHandler = new Handler (handlerFunc: (BuildContext context, Map params) {return PageB ();})
After completing the basic routing configuration, we also need a static overall routing profile, which is convenient for us to use in the routing page. As shown below, is the sample code for the overall routing profile routes.dart.
Import 'package:fluro/fluro.dart';import' package:flutter_demo/route_handles.dart';class Routes {static String page_a = "/"; / / notice that static String page_b = "/ b"; static void configureRoutes (Router router) {router.define (page_a, handler: aHandler); router.define (page_b, handler: bHandler); router.notFoundHandler = emptyHandler; / / empty page}}
In the overall configuration of the route, you also need to deal with paths that do not exist, even if you use an empty page or a default page instead. At the same time, it should be noted that the home page of the application must be configured with "/".
To make it easy to use, you also need to make Router static so that it can be called directly from any page. As shown below, is the sample code for the application.dart file.
Import 'package:fluro/fluro.dart';class Application {static Router router;}
Once you have done this, you can introduce the routing configuration file and static file into the main.dart file, as shown below.
Import 'package:fluro/fluro.dart';import' package:flutter_demo/routes.dart';import 'application.dart';void main () {Router router = Router (); Routes.configureRoutes (router); Application.router = router; runApp (MyApp ());} class MyApp extends StatelessWidget {@ override Widget build (BuildContext context) {return MaterialApp (title:' Demo App', onGenerateRoute: Application.router.generator,);}}
If you want to jump to a page, just use the Application.router.navigateTo () method, as shown below.
Application.router.navigateTo (context, "/ b"); / / b to configure routing
Run the sample code above, and the effect is shown in the following figure.
It can be found that although the use of Fluro is more tedious than Flutter's Navigator, it is very suitable for medium and large projects, and its hierarchical architecture is also very convenient for later project upgrade and maintenance.
These are all the contents of the article "how to use the routing Framework Fluro". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.