Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Support drag-to-dismiss in persistent bottom sheets #1997

Closed
wants to merge 1 commit into from
Closed

Support drag-to-dismiss in persistent bottom sheets #1997

wants to merge 1 commit into from

Conversation

HansMuller
Copy link

Flinging a persistent bottom sheet downwards dismisses it, per the Material spec.

The showBottomSheet() function now returns a Future, like showModalBottomSheet() does, so that you can discover when it's been dismissed - with navigator.pop() - and with what value.

Factored the drag gesture handling code into _BottomSheetDragMixin.


class _ModalBottomSheetState extends State<_ModalBottomSheet> with _BottomSheetDragMixin {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than using a mixin, can we use an object that the state holds as a member? We should eventually share code with Drawer here. I tried to factor a bit of this logic out of Drawer and into DrawerController. We can unify with Drawer in a separate step.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One difference between what I'm doing and DrawerController is that if the bottom sheet is animating I ignore drag gestures. This means that a lightning fingered user might find themselves unable to get in the way of an ongoing show/dismiss. But it also means that code that perhaps erroneously assumes that navigator.pop() will dismiss the sheet will never be foiled by Mr lightning fingers.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever we decide, we should probably be consistent between the two widgets.

@abarth
Copy link
Contributor

abarth commented Nov 6, 2015

LGTM but I think we might be able to share code better with a "has a" pattern rather than an "is a" pattern.

HansMuller pushed a commit to flutter/flutter that referenced this pull request Nov 9, 2015
Support drag-to-dismiss in persistent bottom sheets

Flinging a persistent bottom sheet downwards dismisses it, per the Material spec.

The showBottomSheet() function now returns a Future, like showModalBottomSheet() does, so that you can discover when it's been dismissed - with navigator.pop() - and with what value.

Factored the drag gesture handling code into _BottomSheetDragController

This CL was flutter/engine#1997
@abarth abarth closed this Nov 10, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants