Commit fedaf160 authored by justin's avatar justin Committed by GitHub

Merge pull request #709 from SpiciedCrab/harly-fixedMigrate-1.17

Harly fixed migrate 1.17
parents 04ea791d 657b9540
...@@ -41,7 +41,7 @@ enum ContainerLifeCycle { ...@@ -41,7 +41,7 @@ enum ContainerLifeCycle {
typedef BoostContainerLifeCycleObserver = void Function( typedef BoostContainerLifeCycleObserver = void Function(
ContainerLifeCycle state, ContainerLifeCycle state,
BoostContainerSettings settings, BoostContainerSettings settings,
); );
class BoostContainer extends Navigator { class BoostContainer extends Navigator {
const BoostContainer({ const BoostContainer({
...@@ -122,6 +122,8 @@ class BoostContainer extends Navigator { ...@@ -122,6 +122,8 @@ class BoostContainer extends Navigator {
} }
String desc() => '{uniqueId=${settings.uniqueId},name=${settings.name}}'; String desc() => '{uniqueId=${settings.uniqueId},name=${settings.name}}';
RouteListFactory get initialRoutes => super.onGenerateInitialRoutes;
} }
class BoostContainerState extends NavigatorState { class BoostContainerState extends NavigatorState {
...@@ -161,6 +163,15 @@ class BoostContainerState extends NavigatorState { ...@@ -161,6 +163,15 @@ class BoostContainerState extends NavigatorState {
void initState() { void initState() {
super.initState(); super.initState();
backPressedHandler = () => maybePop(); backPressedHandler = () => maybePop();
final String initRoute = widget.initialRoute ?? Navigator.defaultRouteName;
if (initRoute != null && routerHistory.isEmpty) {
routerHistory.addAll(
widget.initialRoutes(
this,
widget.initialRoute ?? Navigator.defaultRouteName
)
);
}
} }
@override @override
...@@ -177,7 +188,13 @@ class BoostContainerState extends NavigatorState { ...@@ -177,7 +188,13 @@ class BoostContainerState extends NavigatorState {
@override @override
Future<bool> maybePop<T extends Object>([T result]) async { Future<bool> maybePop<T extends Object>([T result]) async {
if(routerHistory.isEmpty) {
pop(result);
return true;
}
final Route<T> route = routerHistory.last as Route<T>; final Route<T> route = routerHistory.last as Route<T>;
final RoutePopDisposition disposition = await route.willPop(); final RoutePopDisposition disposition = await route.willPop();
if (mounted) { if (mounted) {
switch (disposition) { switch (disposition) {
......
...@@ -62,4 +62,9 @@ class BoostPageRoute<T> extends MaterialPageRoute<T> { ...@@ -62,4 +62,9 @@ class BoostPageRoute<T> extends MaterialPageRoute<T> {
return null; return null;
} }
} }
@override
Future<RoutePopDisposition> willPop() {
return Future<RoutePopDisposition>.value(RoutePopDisposition.pop);
}
} }
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