使用fluro来实现flutter中的路由管理,不是很熟练,记录一下。
1.引入
fluro: ^1.5.1
2.application.dart
import 'package:fluro/fluro.dart';
class Application {
static Router router;
}
3.router_Handler.dart
Handler userHandler = Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
print('======>>>>>>');
return userPage();
});
4.routers.dart
class Routes {
static String root = '/';
static String userPage = '/user';
static void configureRoutes(Router router) {
router.notFoundHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
print('ERROR====>ROUTE WAS NOT FONUND!!!'); //错误处理
});
router.define(userPage, handler: userHandler);
}
5.使用
Application.router.navigateTo(context, "/user?");
fluro源码不懂得记录:
pushAndRemoveUntil:将给定路由推送到Navigator,删除先前的路由,直到该函数的参数predicate返回true为止。
pushReplacement:路由替换。
[路由学习参考参考(https://blog.csdn.net/weixin_30512027/article/details/85334391
)