Commit b4c7737e authored by AlexVincent525's avatar AlexVincent525

🎨 Improve code in example/main.dart .

parent 50022e7f
...@@ -16,25 +16,29 @@ class _MyAppState extends State<MyApp> { ...@@ -16,25 +16,29 @@ class _MyAppState extends State<MyApp> {
void initState() { void initState() {
super.initState(); super.initState();
FlutterBoost.singleton.registerPageBuilders({ FlutterBoost.singleton.registerPageBuilders(<String, PageBuilder>{
'embeded': (pageName, params, _) => EmbeddedFirstRouteWidget(), 'embeded': (String pageName, Map<String, dynamic> params, String _) =>
'first': (pageName, params, _) => FirstRouteWidget(), EmbeddedFirstRouteWidget(),
'firstFirst': (pageName, params, _) => FirstFirstRouteWidget(), 'first': (String pageName, Map<String, dynamic> params, String _) => FirstRouteWidget(),
'second': (pageName, params, _) => SecondRouteWidget(), 'firstFirst': (String pageName, Map<String, dynamic> params, String _) =>
'secondStateful': (pageName, params, _) => SecondStatefulRouteWidget(), FirstFirstRouteWidget(),
'tab': (pageName, params, _) => TabRouteWidget(), 'second': (String pageName, Map<String, dynamic> params, String _) => SecondRouteWidget(),
'platformView': (pageName, params, _) => PlatformRouteWidget(), 'secondStateful': (String pageName, Map<String, dynamic> params, String _) =>
'flutterFragment': (pageName, params, _) => FragmentRouteWidget(params), SecondStatefulRouteWidget(),
'tab': (String pageName, Map<String, dynamic> params, String _) => TabRouteWidget(),
'platformView': (String pageName, Map<String, dynamic> params, String _) =>
PlatformRouteWidget(),
'flutterFragment': (String pageName, Map<String, dynamic> params, String _) =>
FragmentRouteWidget(params),
///可以在native层通过 getContainerParams 来传递参数 ///可以在native层通过 getContainerParams 来传递参数
'flutterPage': (pageName, params, _) { 'flutterPage': (String pageName, Map<String, dynamic> params, String _) {
print("flutterPage params:$params"); print('flutterPage params:$params');
return FlutterRouteWidget(params: params); return FlutterRouteWidget(params: params);
}, },
}); });
FlutterBoost.singleton FlutterBoost.singleton.addBoostNavigatorObserver(TestBoostNavigatorObserver());
.addBoostNavigatorObserver(TestBoostNavigatorObserver());
} }
@override @override
...@@ -46,23 +50,32 @@ class _MyAppState extends State<MyApp> { ...@@ -46,23 +50,32 @@ class _MyAppState extends State<MyApp> {
} }
void _onRoutePushed( void _onRoutePushed(
String pageName, String uniqueId, Map params, Route route, Future _) {} String pageName,
String uniqueId,
Map<String, dynamic> params,
Route<dynamic> route,
Future<dynamic> _,
) {}
} }
class TestBoostNavigatorObserver extends NavigatorObserver { class TestBoostNavigatorObserver extends NavigatorObserver {
@override
void didPush(Route<dynamic> route, Route<dynamic> previousRoute) { void didPush(Route<dynamic> route, Route<dynamic> previousRoute) {
print("flutterboost#didPush"); print('flutterboost#didPush');
} }
@override
void didPop(Route<dynamic> route, Route<dynamic> previousRoute) { void didPop(Route<dynamic> route, Route<dynamic> previousRoute) {
print("flutterboost#didPop"); print('flutterboost#didPop');
} }
@override
void didRemove(Route<dynamic> route, Route<dynamic> previousRoute) { void didRemove(Route<dynamic> route, Route<dynamic> previousRoute) {
print("flutterboost#didRemove"); print('flutterboost#didRemove');
} }
@override
void didReplace({Route<dynamic> newRoute, Route<dynamic> oldRoute}) { void didReplace({Route<dynamic> newRoute, Route<dynamic> oldRoute}) {
print("flutterboost#didReplace"); print('flutterboost#didReplace');
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment