How do I enable scrollbar for vertical scroll and disable for horizontal? How do I enable scrollbar for vertical scroll and disable for horizontal? flutter flutter

How do I enable scrollbar for vertical scroll and disable for horizontal?


class NoScrollbar extends StatelessWidget {  final Widget child;  const NoScrollbar({Key key, this.child}) : super(key: key);  @override  Widget build(BuildContext context) {    return NotificationListener<ScrollNotification>(      onNotification: (_) => true,      child: child,    );  }}

Just wrap the NoScrollbar Widget around the Scrolling Widget, you don't want to have the Scrollbar appear. This solved it for me!


Niklas answer did not work for me in Flutter 2.5. I don't know if it's because my layout is different or what. But if you have a PageView (as a carousel for example) inside a ListView the way I found to remove PageView's scrollbar is the following.

Add to Scrollbar widget a notificationPredicate:

notificationPredicate: (ScrollNotification notification) {  return notification.depth == 0 && notification.metrics.axis == Axis.vertical;}

This will only show scrollbar for vertical interactions.

Flutter documentation about notificationPredicate.