@@ -158,7 +158,7 @@ mixin CupertinoRouteTransitionMixin<T> on PageRoute<T> {
158
158
159
159
/// True if an iOS-style back swipe pop gesture is currently underway for [route] .
160
160
///
161
- /// This just check the route's [NavigatorState.userGestureInProgress] .
161
+ /// This just checks the route's [NavigatorState.userGestureInProgress] .
162
162
///
163
163
/// See also:
164
164
///
@@ -293,6 +293,7 @@ mixin CupertinoRouteTransitionMixin<T> on PageRoute<T> {
293
293
child: _CupertinoBackGestureDetector <T >(
294
294
enabledCallback: () => _isPopGestureEnabled <T >(route),
295
295
onStartPopGesture: () => _startPopGesture <T >(route),
296
+ getIsCurrent: () => route.isCurrent,
296
297
child: child,
297
298
),
298
299
);
@@ -596,6 +597,7 @@ class _CupertinoBackGestureDetector<T> extends StatefulWidget {
596
597
required this .enabledCallback,
597
598
required this .onStartPopGesture,
598
599
required this .child,
600
+ required this .getIsCurrent,
599
601
});
600
602
601
603
final Widget child;
@@ -604,6 +606,8 @@ class _CupertinoBackGestureDetector<T> extends StatefulWidget {
604
606
605
607
final ValueGetter <_CupertinoBackGestureController <T >> onStartPopGesture;
606
608
609
+ final ValueGetter <bool > getIsCurrent;
610
+
607
611
@override
608
612
_CupertinoBackGestureDetectorState <T > createState () => _CupertinoBackGestureDetectorState <T >();
609
613
}
@@ -613,8 +617,6 @@ class _CupertinoBackGestureDetectorState<T> extends State<_CupertinoBackGestureD
613
617
614
618
late HorizontalDragGestureRecognizer _recognizer;
615
619
616
- int ? _trackedPointer;
617
-
618
620
@override
619
621
void initState () {
620
622
super .initState ();
@@ -656,6 +658,13 @@ class _CupertinoBackGestureDetectorState<T> extends State<_CupertinoBackGestureD
656
658
void _handleDragEnd (DragEndDetails details) {
657
659
assert (mounted);
658
660
assert (_backGestureController != null );
661
+ // TODO(justinmc): Why can't I drag to go back on page 3 after this?
662
+ print ('justin _handleDragEnd. ${widget .getIsCurrent ()}' );
663
+ if (! widget.getIsCurrent ()) {
664
+ _backGestureController? .dragEnd (0.0 );
665
+ _backGestureController = null ;
666
+ return ;
667
+ }
659
668
_backGestureController! .dragEnd (_convertToLogical (details.velocity.pixelsPerSecond.dx / context.size! .width));
660
669
_backGestureController = null ;
661
670
}
@@ -671,14 +680,9 @@ class _CupertinoBackGestureDetectorState<T> extends State<_CupertinoBackGestureD
671
680
void _handlePointerDown (PointerDownEvent event) {
672
681
if (widget.enabledCallback ()) {
673
682
_recognizer.addPointer (event);
674
- _trackedPointer = event.pointer;
675
683
}
676
684
}
677
685
678
- void _handlePointerUp (PointerUpEvent event) {
679
- _trackedPointer = null ;
680
- }
681
-
682
686
double _convertToLogical (double value) {
683
687
switch (Directionality .of (context)) {
684
688
case TextDirection .rtl:
@@ -697,30 +701,21 @@ class _CupertinoBackGestureDetectorState<T> extends State<_CupertinoBackGestureD
697
701
MediaQuery .paddingOf (context).left :
698
702
MediaQuery .paddingOf (context).right;
699
703
dragAreaWidth = max (dragAreaWidth, _kBackGestureWidth);
700
- return PopScope (
701
- onPopInvoked: (bool didPop) {
702
- if (! didPop || _trackedPointer == null ) {
703
- return ;
704
- }
705
- _recognizer.rejectGesture (_trackedPointer! );
706
- },
707
- child: Stack (
708
- fit: StackFit .passthrough,
709
- children: < Widget > [
710
- widget.child,
711
- PositionedDirectional (
712
- start: 0.0 ,
713
- width: dragAreaWidth,
714
- top: 0.0 ,
715
- bottom: 0.0 ,
716
- child: Listener (
717
- onPointerDown: _handlePointerDown,
718
- onPointerUp: _handlePointerUp,
719
- behavior: HitTestBehavior .translucent,
720
- ),
704
+ return Stack (
705
+ fit: StackFit .passthrough,
706
+ children: < Widget > [
707
+ widget.child,
708
+ PositionedDirectional (
709
+ start: 0.0 ,
710
+ width: dragAreaWidth,
711
+ top: 0.0 ,
712
+ bottom: 0.0 ,
713
+ child: Listener (
714
+ onPointerDown: _handlePointerDown,
715
+ behavior: HitTestBehavior .translucent,
721
716
),
722
- ] ,
723
- ) ,
717
+ ) ,
718
+ ] ,
724
719
);
725
720
}
726
721
}
0 commit comments