rubber
rubber copied to clipboard
Disable scroll in upperLayer when state is not AnimationState.expanded
i'm using a ListView
for my upperLayer
. When the AnimationState
is half_expanded
or collapsed
i can scroll the ListView
. I need to disable the scroll in this states and just enable it in expanded
. How can i achieve this?
You can achieve this by using passing a scrollController
to the RubberBottomSheet
and setting the same scrollController
in the listView, along with NeverScrollablePhysics
.
See https://github.com/mcrovero/rubber/wiki/Scrolling for a full example.
There is a bug in this, where scrolling the ListView
is still possible, even when the sheet is in a collapsed
state. This happens when the sheet is programmatically collapsed via collapse
or fling
, and when the scrollOffset of the list is programatically set to 0, from a non-zero value.
In my app, I allow users to scroll up and down the ListView
, but pressing a button will collapse the bottom sheet to reveal another widget underneath the sheet. As such, I programmatically set the scroll offset using jumpTo(0)
, and collapse the bottom sheet with fling
. RubberBottomSheet
toggles between scrolling of the ListView
and dragging of the sheet in RubberBottomSheet._onVerticalDragUpdate
, using the _setScrolling
function. It decides this based on the scrollPosition
of the scrollController
passed into the constructor. Hence, it is not able to detect that it's supposed to drag the sheet instead of scrolling the ListView
, when the ListView
is programmatically scrolled to the top.