Skip to content

Commit abdaa55

Browse files
committed
using 'airoute' route package.
1 parent 0a88ab2 commit abdaa55

File tree

4 files changed

+38
-58
lines changed

4 files changed

+38
-58
lines changed

lib/main.dart

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -20,51 +20,40 @@ import 'package:flutter_app_sample/sample/notifier/CardMainPage.dart';
2020
import 'package:flutter_app_sample/sample/notifier/CardInfoPage.dart';
2121
import 'package:flutter_app_sample/sample/drag/DragListPage.dart';
2222
import 'package:flutter_app_sample/sample/DrawerVariouslyPage.dart';
23-
import 'package:flutter_route/flutter_route.dart';
23+
import 'package:airoute/airoute.dart';
2424

2525
// Register the RouteObserver as a navigation observer.
2626
@deprecated //2019
2727
final RouteObserver<PageRoute> routeObserver = RouteObserver<PageRoute>();
2828

29-
void main() => runApp(MaterialApp(
29+
void main() => runApp(Airoute.createMaterialApp(
3030
home: Scaffold(
3131
body: LoginPage(),
3232
),
3333

3434
///全局静态路由的配置!
35-
routes: RouteManager.initializeRoutes(
36-
routes: <String, WidgetBuilder>{
37-
"LoginPage": (BuildContext context) => LoginPage(),
38-
"MainPage": (BuildContext context) => MainPage(),
39-
"TestPage": (BuildContext context) => TestPage(),
40-
"ShoppingList": (BuildContext context) => ShoppingListPage(),
41-
"MainSortListPage": (BuildContext context) => MainSortListPage(),
42-
"ViewPagerFragmentPage": (BuildContext context) =>
43-
ViewPagerFragmentPage(),
44-
"CollapsingToolbarPage": (BuildContext context) =>
45-
CollapsingToolbarPage(),
46-
"MainAnimSortPage": (BuildContext context) => MainAnimSortPage(),
47-
"AnimOfSwitchPage": (BuildContext context) => AnimOfSwitchPage(),
48-
"AnimatedContainerPage": (BuildContext context) =>
49-
AnimatedContainerPage(),
50-
"OpacityAndAnimatedOpacityPage": (BuildContext context) =>
51-
OpacityAndAnimatedOpacityPage(),
52-
"FadeInImagePage": (BuildContext context) => FadeInImagePage(),
53-
"HeroAnimPage": (BuildContext context) => HeroAnimPage(),
54-
"TransformPage": (BuildContext context) => TransformPage(),
55-
"AnimatedBuilderPage": (BuildContext context) =>
56-
AnimatedBuilderPage(),
57-
"ColorTweenPage": (BuildContext context) => ColorTweenPage(),
58-
"CardMainPage": (BuildContext context) => CardMainPage(),
59-
"CardInfoPage": (BuildContext context) => CardInfoPage(),
60-
"DragListPage": (BuildContext context) => DragListPage(),
61-
"DrawerVariouslyPage": (BuildContext context) =>
62-
DrawerVariouslyPage(),
63-
},
64-
),
65-
navigatorObservers: [
66-
RouteManager.getInstance(),
67-
],
35+
routes: <String, AirouteBuilder>{
36+
"LoginPage": () => LoginPage(),
37+
"MainPage": () => MainPage(),
38+
"TestPage": () => TestPage(),
39+
"ShoppingList": () => ShoppingListPage(),
40+
"MainSortListPage": () => MainSortListPage(),
41+
"ViewPagerFragmentPage": () => ViewPagerFragmentPage(),
42+
"CollapsingToolbarPage": () => CollapsingToolbarPage(),
43+
"MainAnimSortPage": () => MainAnimSortPage(),
44+
"AnimOfSwitchPage": () => AnimOfSwitchPage(),
45+
"AnimatedContainerPage": () => AnimatedContainerPage(),
46+
"OpacityAndAnimatedOpacityPage": () => OpacityAndAnimatedOpacityPage(),
47+
"FadeInImagePage": () => FadeInImagePage(),
48+
"HeroAnimPage": () => HeroAnimPage(),
49+
"TransformPage": () => TransformPage(),
50+
"AnimatedBuilderPage": () => AnimatedBuilderPage(),
51+
"ColorTweenPage": () => ColorTweenPage(),
52+
"CardMainPage": () => CardMainPage(),
53+
"CardInfoPage": () => CardInfoPage(),
54+
"DragListPage": () => DragListPage(),
55+
"DrawerVariouslyPage": () => DrawerVariouslyPage(),
56+
},
6857
));
6958

7059
class MyApp extends AppCommonStatefulPage {

lib/sample/MainSortListPage.dart

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_app_sample/ui/base/AppCommonStatefulPage.dart';
33
import 'CollapsingToolbarPage.dart';
4+
import 'package:airoute/airoute.dart';
45

56
class MainSortListPage extends AppCommonStatefulPage {
67
String titleName = "主页";
@@ -93,10 +94,8 @@ class MainSortListPage extends AppCommonStatefulPage {
9394
color: Colors.blue,
9495
textColor: Colors.white,
9596
onPressed: () {
96-
pushNamed(
97+
Airoute.pushNamed(
9798
routeName: "ViewPagerFragmentPage",
98-
enterParameter:
99-
EnterParameter(previousPageContext: getContext()),
10099
);
101100
},
102101
child: Text("Toolbar+ViewPager+Fragment"),
@@ -105,10 +104,8 @@ class MainSortListPage extends AppCommonStatefulPage {
105104
color: Colors.blue,
106105
textColor: Colors.white,
107106
onPressed: () {
108-
pushNamed(
107+
Airoute.pushNamed(
109108
routeName: "CollapsingToolbarPage",
110-
enterParameter:
111-
EnterParameter(previousPageContext: getContext()),
112109
);
113110
},
114111
child: Text("Collapsing+Toolbar+Fragment"),
@@ -117,10 +114,8 @@ class MainSortListPage extends AppCommonStatefulPage {
117114
color: Colors.blue,
118115
textColor: Colors.white,
119116
onPressed: () {
120-
pushNamed(
117+
Airoute.pushNamed(
121118
routeName: "MainAnimSortPage",
122-
enterParameter:
123-
EnterParameter(previousPageContext: getContext()),
124119
);
125120
},
126121
child: Text("Animation"),
@@ -202,10 +197,8 @@ class MainSortListPage extends AppCommonStatefulPage {
202197
color: Colors.blue,
203198
textColor: Colors.white,
204199
onPressed: () {
205-
pushNamed(
200+
Airoute.pushNamed(
206201
routeName: "CardMainPage",
207-
enterParameter:
208-
EnterParameter(previousPageContext: getContext()),
209202
);
210203
},
211204
child: Text("组件间通信"),
@@ -214,10 +207,8 @@ class MainSortListPage extends AppCommonStatefulPage {
214207
color: Colors.blue,
215208
textColor: Colors.white,
216209
onPressed: () {
217-
pushNamed(
210+
Airoute.pushNamed(
218211
routeName: "DragListPage",
219-
enterParameter:
220-
EnterParameter(previousPageContext: getContext()),
221212
);
222213
},
223214
child: Text("Drag拖拽"),

lib/sample/anim/MainAnimSortPage.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_app_sample/ui/base/AppCommonStatefulPage.dart';
3+
import 'package:airoute/airoute.dart';
34

45
class MainAnimSortPage extends AppCommonStatefulPage {
56
var _titleName = "动画";
@@ -123,14 +124,14 @@ class MainAnimSortPage extends AppCommonStatefulPage {
123124
/*
124125
跳转到动画详情页
125126
*/
126-
pushNamed(
127+
Airoute.pushNamed(
127128
routeName: _listRouteNames.elementAt(i),
128-
enterParameter:
129-
EnterParameter(previousPageContext: getContext()),
130129
);
131130
},
132131
child: Card(
133-
shape: RoundedRectangleBorder(side: BorderSide(color: Colors.green, width: 1), borderRadius: BorderRadius.circular(5)),
132+
shape: RoundedRectangleBorder(
133+
side: BorderSide(color: Colors.green, width: 1),
134+
borderRadius: BorderRadius.circular(5)),
134135
elevation: 5,
135136
margin: EdgeInsets.all(5),
136137
child: Padding(
@@ -186,9 +187,8 @@ class MainAnimSortPage extends AppCommonStatefulPage {
186187
/*
187188
跳转到动画详情页
188189
*/
189-
pushNamed(
190+
Airoute.pushNamed(
190191
routeName: _listRouteNames.elementAt(index),
191-
enterParameter: EnterParameter(previousPageContext: getContext()),
192192
);
193193
},
194194
color: Colors.blue,

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ dependencies:
2828
provider: ^3.0.0
2929

3030
# Route package.
31-
flutter_route:
31+
airoute:
3232
git:
33-
url: https://github.com/pdliuw/flutter_route.git
33+
url: https://github.com/pdliuw/airoute.git
3434

3535
dev_dependencies:
3636
flutter_test:

0 commit comments

Comments
 (0)