Photo by Alvin Balemesa on Unsplash

Before we're going to learn how to use Scrollbar in Flutter, let's know one important fact about this widget. This widget belongs to Scrolling Widgets; and, we have a category dedicated to these widgets.

Therefore, you may want to take a look at the other Scrolling Widgets, we have a list below.

What is ListView Flutter? How do I use ListView in Flutter?

How do I use SingleChildScrollView in flutter?

What is GridView and how do you centre a GridView item in Flutter?

What is GridView builder in Flutter?

What is the grid view in Flutter?

What is GridView count in flutter?

What is GridView.extent in Flutter?

How do I make my collapsing toolbar flutter?

What is SliverGrid in flutter?

How to use CustomScrollView in Flutter?

How to use NestedScrollView in flutter?

How to use PageView in Flutter

What is PageView builder in flutter?

What is PageView custom in flutter?

How to use DraggableScrollableSheet

Not only Scrollbar widget belongs to only Scrolling widgets, but also it's a Material Design widget.

To add a Scrollbar, we need to have a ScrollView. Why? Because we can only add a Scrollbar to a ScrollView; otherwise, it doesn't make any sense.

To make our point strong, let's see the screenshot of a flutter app that we've built for this purpose.

Scrollbar in flutter
Scrollbar in flutter

As the above screenshot displays, our items are not many. We have only 10 items to show on the screen. As a result, our Scrollbar thumb looks bigger.

What if we've added more items on the screen?

As a result the Scrollbar thumb gets smaller. As we scroll vertically, the Scrollbar thumb moves.

The Scrollbar thumb shows the exact spot of the ScrollView, which is actually visible

By the way, in our code, as a ScrollView widget we've used ListView.builder constructor of ListView widget.

Therefore, now it makes sense if we take a look at the full code. After that, we'll discuss a few parts of the code to understand Scrollbar widget in great detail.

Further Reading >>


This free site is ad-supported. Learn more