English Document | 中文文档 |
---|
*1、支持无需context的路由管理,
*2、支持‘非侵入式参数传递’的路由管理,
*3、让你爱上路由管理的airoute
Airoute 在项目中的实战应用flutter sample
iOS | Android |
---|---|
:- | :- |
macOS | web |
---|---|
:- | :- |
使用当前包作为依赖库
在文件 'pubspec.yaml' 中添加
dependencies:
airoute: ^version
或以这种方式添加
# Route package.
airoute:
git:
url: https://github.com/pdliuw/airoute.git
你可以通过下面的命令行来安装此库
$ flutter pub get
你也可以通过项目开发工具通过可视化操作来执行上述步骤
现在,在你的Dart编辑代码中,你可以使用:
import 'package:airoute/airoute.dart';
Airoute 全局配置
void main() {
runApp(
///
/// 配置Airoute
Airoute.createMaterialApp(
home: LaunchPage(),
routes: <String, WidgetBuilder>{
"/LaunchPage": (_) => LaunchPage(),
"/SecondPage": (_) => SecondPage(),
},
),
);
}
*1、跳转新页面
Airoute.pushNamed(routeName: "/routeName");
*2、关闭页面
Airoute.pop();
*3、跳转新页面,并添加动画
Airoute.pushNamedWithAnimation(
routeName: "/routeName",
routePageAnimation: AirouteTransition.Slide);
*4、传递参数、接收参数
传递参数
Airoute.pushNamed(
routeName: "/Page",
argument: "遇见你,我很开心😄😄😄",
);
传递number参数
Airoute.pushNamed(
routeName: "/SecondPage",
argument: 0,
);
传递Map参数
Airoute.pushNamed(
routeName: "/Page",
argument: {
"account":"this is accont",
"password":"this is password ",
},
传递Array参数
Airoute.pushNamed(
routeName: "/Page",
argument: [
"Air",
"James",
"Lucy",
"Tom",
],
);
接收参数
class Page extends StatefulWidget with AirArgumentReceiver {
@override
State<StatefulWidget> createState() {
return _PageState();
}
@override
void receive(AirArgument argument) {
print("收到${argument.argument}参数了,我很开心😄😄😄");
}
}
*5、路由跳转
Airoute.push(
route: AwesomeMessageRoute(
awesomeMessage: AwesomeHelper.createAwesome(
title: "title", message: "message"),
theme: null,
settings: RouteSettings(name: "/messageRouteName"),
),
);
*6、更多用法点击,查看更多
- 支持: 路由拦截器.
BSD 3-Clause License
Copyright (c) 2020, pdliuw
All rights reserved.