Filip
Filip

Reputation: 2411

Flutter web - scroll down but horizontal

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?

Upvotes: 2

Views: 414

Answers (1)

devrob
devrob

Reputation: 33

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: ...,
  ),
)

Upvotes: 2

Related Questions