[cupertino_ui] Prevent intercepting CupertinoSheet transitions mid-animation - #12515
[cupertino_ui] Prevent intercepting CupertinoSheet transitions mid-animation#12515xxxOVALxxx wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request prevents drag gestures from interrupting the Cupertino sheet's dismissal animation by updating enabledCallback to check if the route controller is currently animating, and adding a check for enabledCallback in _CupertinoDraggableScrollableSheetState._dragStart. A widget test is also added to verify this behavior. The reviewer suggests also checking widget.enabledCallback() in _handleDragStart within _CupertinoDragGestureDetectorState to handle cases where an animation starts after a pointer is downed but before the drag gesture begins.
| topGap: topGap, | ||
| child: _CupertinoDragGestureDetector<T>( | ||
| enabledCallback: () => enableDrag, | ||
| enabledCallback: () => enableDrag && !(route.controller?.isAnimating ?? false), |
There was a problem hiding this comment.
While enabledCallback is now correctly updated to check if the route is animating, _CupertinoDragGestureDetectorState only checks enabledCallback() during onPointerDown (line 1059).
If a programmatic animation starts after the pointer is downed but before the drag gesture actually starts (i.e., before the pointer moves enough to trigger onStart), _handleDragStart will still be called and will initiate the pop gesture, potentially intercepting the animation.
To make this fully robust and consistent with _CupertinoDraggableScrollableSheetState (which checks enabledCallback in _dragStart), consider also checking widget.enabledCallback() in _handleDragStart and handling a null _dragGestureController in _handleDragUpdate and _handleDragEnd.
Fixed an incompatibility between CupertinoSheetRoute and SwiftUI sheet, which allowed users to intercept animations for opening and closing a CupertinoSheetRoute, resulting in unexpected gesture behavior and animation failures.
This PR is a follow-up to flutter/flutter#181605
Pre-Review Checklist
[shared_preferences]///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2