Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clicking on the modal barrier during dragging will cause an error #54

Closed
huahua8893 opened this issue Feb 28, 2024 · 1 comment · Fixed by #62
Closed

Clicking on the modal barrier during dragging will cause an error #54

huahua8893 opened this issue Feb 28, 2024 · 1 comment · Fixed by #62
Assignees
Labels
bug Something isn't working P1

Comments

@huahua8893
Copy link

Great work and great doc, but I found a problem that click on the background page during dragging will cause an error, like this:

Record_2024-02-28-10-23-43.mp4

Use "cupertino_modal_sheet.dart" demo can see this

And I will submit another issue for a new feature request

@fujidaiti
Copy link
Owner

fujidaiti commented Feb 28, 2024

I tried to reproduce this issue and found that an unexpected pop event occurs when the barrier is tapped.

Error Log
════════ Exception caught by gesture ═══════════════════════════════════════════
The following RangeError was thrown while handling a gesture:
RangeError (index): Invalid value: Only valid value is 0: -1

When the exception was thrown, this was the stack:
#0      List.[] (dart:core-patch/growable_array.dart:264:36)
#1      _History.[] (package:flutter/src/widgets/navigator.dart:3474:18)
#2      NavigatorState.didStartUserGesture (package:flutter/src/widgets/navigator.dart:5457:44)
#3      _SheetDismissibleState._handleDragStart (package:smooth_sheets/src/modal/modal_sheet.dart:249:29)
#4      _DragGestureRecognizer._checkStart.<anonymous closure> (package:smooth_sheets/src/internal/monodrag.dart:543:53)
#5      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:315:24)
#6      _DragGestureRecognizer._checkStart (package:smooth_sheets/src/internal/monodrag.dart:543:7)
#7      _DragGestureRecognizer._checkDrag (package:smooth_sheets/src/internal/monodrag.dart:507:5)
#8      _DragGestureRecognizer.acceptGesture (package:smooth_sheets/src/internal/monodrag.dart:440:7)
#9      GestureArenaManager._resolveInFavorOf (package:flutter/src/gestures/arena.dart:281:12)
#10     GestureArenaManager._resolve (package:flutter/src/gestures/arena.dart:239:9)
#11     GestureArenaEntry.resolve (package:flutter/src/gestures/arena.dart:53:12)
#12     OneSequenceGestureRecognizer.resolve (package:flutter/src/gestures/recognizer.dart:415:13)
#13     _DragGestureRecognizer.handleEvent (package:smooth_sheets/src/internal/monodrag.dart:421:13)
#14     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:98:12)
#15     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:143:9)
#16     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633:13)
#17     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
#18     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127:7)
#19     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:495:19)
#20     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:475:22)
#21     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:430:11)
#22     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:420:7)
#23     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:383:5)
#24     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:330:7)
#25     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:299:9)
#26     _invoke1 (dart:ui/hooks.dart:328:13)
#27     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:429:7)
#28     _dispatchPointerDataPacket (dart:ui/hooks.dart:262:31)

Handler: "onStart"
Recognizer: _PullToDismissGestureRecognizer#804c6
    debugOwner: _SheetDismissibleState#e7785
    start behavior: start
════════════════════════════════════════════════════════════════════════════════

Probably I'll disable route poping during a pull-to-dismiss action.

@fujidaiti fujidaiti self-assigned this Feb 28, 2024
@fujidaiti fujidaiti added bug Something isn't working P1 labels Feb 28, 2024
@fujidaiti fujidaiti changed the title Clicking on the following page during dragging will cause an error Clicking on the modal barrier during dragging will cause an error Feb 29, 2024
fujidaiti added a commit that referenced this issue Mar 8, 2024
This PR fixes #54.

A modal sheet can now be dismissed by clicking the barrier ONLY when its
status is `SheetStatus.stable` and the pull-to-dismiss action is not
running.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants