Commit 12b52d25 authored by 尘萧's avatar 尘萧

修复切换页面滑动失效的问题

parent 12ffd101
...@@ -118,6 +118,8 @@ class BoostContainer extends Navigator { ...@@ -118,6 +118,8 @@ class BoostContainer extends Navigator {
class BoostContainerState extends NavigatorState { class BoostContainerState extends NavigatorState {
VoidCallback backPressedHandler; VoidCallback backPressedHandler;
VoidCallback lifeCycleObserverRemove;
String get uniqueId => widget.settings.uniqueId; String get uniqueId => widget.settings.uniqueId;
String get name => widget.settings.name; String get name => widget.settings.name;
...@@ -135,6 +137,8 @@ class BoostContainerState extends NavigatorState { ...@@ -135,6 +137,8 @@ class BoostContainerState extends NavigatorState {
@override @override
BoostContainer get widget => super.widget as BoostContainer; BoostContainer get widget => super.widget as BoostContainer;
final Set<int> _activePointers = <int>{};
List<Route<dynamic>> routerHistory = <Route<dynamic>>[]; List<Route<dynamic>> routerHistory = <Route<dynamic>>[];
bool multipleRouteMode = false; bool multipleRouteMode = false;
...@@ -154,6 +158,12 @@ class BoostContainerState extends NavigatorState { ...@@ -154,6 +158,12 @@ class BoostContainerState extends NavigatorState {
void initState() { void initState() {
super.initState(); super.initState();
backPressedHandler = () => maybePop(); backPressedHandler = () => maybePop();
lifeCycleObserverRemove = addLifeCycleObserver(
(ContainerLifeCycle state, BoostContainerSettings settings) {
if (state == ContainerLifeCycle.Disappear){
_cancelActivePointers();
}
});
} }
@override @override
...@@ -167,6 +177,8 @@ class BoostContainerState extends NavigatorState { ...@@ -167,6 +177,8 @@ class BoostContainerState extends NavigatorState {
GlobalRouteSettingsManager.instance.removeSettings(route); GlobalRouteSettingsManager.instance.removeSettings(route);
} }
lifeCycleObserverRemove();
routerHistory.clear(); routerHistory.clear();
super.dispose(); super.dispose();
...@@ -259,6 +271,28 @@ class BoostContainerState extends NavigatorState { ...@@ -259,6 +271,28 @@ class BoostContainerState extends NavigatorState {
return future; return future;
} }
@override
Widget build(BuildContext context) {
return Listener(
onPointerDown: _handlePointerDown,
onPointerUp: _handlePointerUpOrCancel,
onPointerCancel: _handlePointerUpOrCancel,
child: super.build(context),
);
}
void _handlePointerDown(PointerDownEvent event) {
_activePointers.add(event.pointer);
}
void _handlePointerUpOrCancel(PointerEvent event) {
_activePointers.remove(event.pointer);
}
void _cancelActivePointers() {
_activePointers.toList().forEach(WidgetsBinding.instance.cancelPointer);
}
VoidCallback addLifeCycleObserver(BoostContainerLifeCycleObserver observer) { VoidCallback addLifeCycleObserver(BoostContainerLifeCycleObserver observer) {
return FlutterBoost.singleton.addBoostContainerLifeCycleObserver( return FlutterBoost.singleton.addBoostContainerLifeCycleObserver(
(ContainerLifeCycle state, BoostContainerSettings settings) { (ContainerLifeCycle state, BoostContainerSettings settings) {
......
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