the effect I want to achieve is that the user scrolls sideways when the user uses the gesture to scroll down. Something like on this page.
ListView does not work with gestures - but it does work with a mouse, but that doesn't solve the problem when the user is using gestures, e.g. on a laptop.
Does anyone have an idea how to handle it?
asked Aug 10, 2020 at 16:35
Filip
2,4614 gold badges15 silver badges28 bronze badges
-
Read about Scrollable classes in flutter. It will help you get some clarity, which one to useAlok– Alok2020年08月10日 18:11:41 +00:00Commented Aug 10, 2020 at 18:11
1 Answer 1
I did not find any dedicated functionality in some widget, but here is my workaround:
final scrollController = ScrollController();
Listener(
onPointerSignal: (pointerSignal) {
if (pointerSignal is PointerScrollEvent) {
scrollController.animateTo(
scrollController.offset + pointerSignal.scrollDelta.dy,
curve: Curves.decelerate,
duration: const Duration(milliseconds: 200),
);
}
},
child: SingleChildScrollView( // or any other
controller: scrollController,
child: ...,
),
)
Sign up to request clarification or add additional context in comments.
Comments
lang-dart