Commit 983669ee authored by 余玠's avatar 余玠

add demo to log the flutter page's disposing event

parent 9961047f
...@@ -19,6 +19,7 @@ class _MyAppState extends State<MyApp> { ...@@ -19,6 +19,7 @@ class _MyAppState extends State<MyApp> {
FlutterBoost.singleton.registerPageBuilders({ FlutterBoost.singleton.registerPageBuilders({
'embeded': (pageName, params, _)=>EmbededFirstRouteWidget(), 'embeded': (pageName, params, _)=>EmbededFirstRouteWidget(),
'first': (pageName, params, _) => FirstRouteWidget(), 'first': (pageName, params, _) => FirstRouteWidget(),
'firstFirst': (pageName, params, _) => FirstFirstRouteWidget(),
'second': (pageName, params, _) => SecondRouteWidget(), 'second': (pageName, params, _) => SecondRouteWidget(),
'tab': (pageName, params, _) => TabRouteWidget(), 'tab': (pageName, params, _) => TabRouteWidget(),
'platformView': (pageName, params, _) => PlatformRouteWidget(), 'platformView': (pageName, params, _) => PlatformRouteWidget(),
......
...@@ -3,7 +3,45 @@ import 'package:flutter/material.dart'; ...@@ -3,7 +3,45 @@ import 'package:flutter/material.dart';
import 'package:flutter_boost/flutter_boost.dart'; import 'package:flutter_boost/flutter_boost.dart';
import 'package:flutter_boost_example/platform_view.dart'; import 'package:flutter_boost_example/platform_view.dart';
class FirstRouteWidget extends StatelessWidget { class FirstRouteWidget extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return new _FirstRouteWidgetState();
}
}
class _FirstRouteWidgetState extends State<FirstRouteWidget>{
_FirstRouteWidgetState();
@override
void initState() {
print('initState');
super.initState();
}
@override
void didChangeDependencies() {
print('didChangeDependencies');
super.didChangeDependencies();
}
@override
void didUpdateWidget(FirstRouteWidget oldWidget) {
print('didUpdateWidget');
super.didUpdateWidget(oldWidget);
}
@override
void deactivate() {
print('deactivate');
super.deactivate();
}
@override
void dispose() {
print('[XDEBUG] - FirstRouteWidget is disposing~');
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
...@@ -26,9 +64,18 @@ class FirstRouteWidget extends StatelessWidget { ...@@ -26,9 +64,18 @@ class FirstRouteWidget extends StatelessWidget {
}); });
}, },
), ),
RaisedButton( RaisedButton(
child: Text('Open second route'), child: Text('Open FF route'),
onPressed: () {
print("open FF page!");
FlutterBoost.singleton.open("firstFirst").then((Map value) {
print(
"call me when page is finished. did recieve FF route result $value");
});
},
),
RaisedButton(
child: Text('Open second route1'),
onPressed: () { onPressed: () {
print("open second page!"); print("open second page!");
FlutterBoost.singleton.open("second").then((Map value) { FlutterBoost.singleton.open("second").then((Map value) {
...@@ -54,14 +101,87 @@ class FirstRouteWidget extends StatelessWidget { ...@@ -54,14 +101,87 @@ class FirstRouteWidget extends StatelessWidget {
); );
} }
} }
class FirstFirstRouteWidget extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return new _FirstFirstRouteWidgetState();
}
}
class _FirstFirstRouteWidgetState extends State<FirstFirstRouteWidget>{
_FirstFirstRouteWidgetState();
@override
void initState() {
print('initState');
super.initState();
}
class EmbededFirstRouteWidget extends StatelessWidget { @override
void didChangeDependencies() {
print('didChangeDependencies');
super.didChangeDependencies();
}
@override
void didUpdateWidget(FirstFirstRouteWidget oldWidget) {
print('didUpdateWidget');
super.didUpdateWidget(oldWidget);
}
@override
void deactivate() {
print('deactivate');
super.deactivate();
}
@override
void dispose() {
print('[XDEBUG] - FirstFirstRouteWidget is disposing~');
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('First Route'),
),
body: Center(
child: RaisedButton(
child: Text('Open first route'),
onPressed: () {
print("open first page again!");
FlutterBoost.singleton.open("first").then((Map value){
print("did recieve first route result");
print("did recieve first route result $value");
});
},
),
),
);
}
}
class EmbededFirstRouteWidget extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return _EmbededFirstRouteWidgetState();
}
}
class _EmbededFirstRouteWidgetState extends State<EmbededFirstRouteWidget> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
print('_EmbededFirstRouteWidgetState build called!');
return Scaffold( return Scaffold(
body: Center( body: Center(
child: RaisedButton( child: RaisedButton(
child: Text('Open second route'), child: Text('Open second route2'),
onPressed: () { onPressed: () {
print("open second page!"); print("open second page!");
FlutterBoost.singleton.open("second").then((Map value) { FlutterBoost.singleton.open("second").then((Map value) {
...@@ -73,6 +193,11 @@ class EmbededFirstRouteWidget extends StatelessWidget { ...@@ -73,6 +193,11 @@ class EmbededFirstRouteWidget extends StatelessWidget {
), ),
); );
} }
@override
void dispose() {
print('[XDEBUG]:_EmbededFirstRouteWidgetState dispose called!');
super.dispose();
}
} }
class SecondRouteWidget extends StatelessWidget { class SecondRouteWidget extends StatelessWidget {
...@@ -111,7 +236,7 @@ class TabRouteWidget extends StatelessWidget { ...@@ -111,7 +236,7 @@ class TabRouteWidget extends StatelessWidget {
onPressed: () { onPressed: () {
FlutterBoost.singleton.open("second"); FlutterBoost.singleton.open("second");
}, },
child: Text('Open second route'), child: Text('Open second route3'),
), ),
), ),
); );
......
...@@ -183,9 +183,11 @@ class ContainerManagerState extends State<BoostContainerManager> { ...@@ -183,9 +183,11 @@ class ContainerManagerState extends State<BoostContainerManager> {
if (SchedulerBinding.instance.schedulerPhase == if (SchedulerBinding.instance.schedulerPhase ==
SchedulerPhase.persistentCallbacks) { SchedulerPhase.persistentCallbacks) {
SchedulerBinding.instance.addPostFrameCallback((Duration duration) { SchedulerBinding.instance.addPostFrameCallback((Duration duration) {
Logger.log('_refreshOverlayEntries in addPostFrameCallback');
_refreshOverlayEntries(); _refreshOverlayEntries();
}); });
} else { } else {
Logger.log('_refreshOverlayEntries in setState');
_refreshOverlayEntries(); _refreshOverlayEntries();
} }
......
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