flutter_improved_scrolling icon indicating copy to clipboard operation
flutter_improved_scrolling copied to clipboard

The scrollbar doesn't work (by clicking and dragging with a mouse)

Open tomc128 opened this issue 2 years ago • 0 comments

I've just implemented this package in my app. Mouse wheel scrolling works great, however now clicking and draging on the scrollbar does not work, it simply stays in place and does not scroll. This happens both using a CustomScrollBehaviour as per the example app, and without. My example below uses a CustomScrollView, however this issue persists with a regular ListView as well.

My code:

ImprovedScrolling(
  scrollController: _scrollController,
  enableMMBScrolling: false,
  enableCustomMouseWheelScrolling: true,
  enableKeyboardScrolling: false,
  customMouseWheelScrollConfig: const CustomMouseWheelScrollConfig(
    scrollAmountMultiplier: 3.0,
    scrollDuration: Duration(milliseconds: 500),
  ),
  child: ScrollConfiguration(
    behavior: const CustomScrollBehaviour(),
    child: CustomScrollView(
      controller: _scrollController,
      physics: const NeverScrollableScrollPhysics(),
      slivers: [
        SliverGrid(...),
      ],
    ),
  ),
);

and:

class CustomScrollBehaviour extends MaterialScrollBehavior {
  const CustomScrollBehaviour();

  @override
  Widget buildScrollbar(BuildContext context, Widget child, ScrollableDetails details) {
    return switch (getPlatform(context)) {
      TargetPlatform.linux || TargetPlatform.macOS || TargetPlatform.windows => Scrollbar(
          controller: details.controller,
          thumbVisibility: false,
          interactive: true,
          child: child,
        ),
      _ => child,
    };
  }
}

tomc128 avatar Jun 11 '23 20:06 tomc128