Flutter Tip: Show scrollbar in ListView

Dhrumil Shah
FlutterFlakes
Published in
2 min readApr 22, 2020

ListView is a very common and very widely used widget in Flutter app development to show a list of items that a user can scroll.

Sometimes it becomes difficult for the user to decide whether the screen is scrollable or not because a user is not able to see the scrollbar on the screen.

Flutter ListView widget does not provide the inbuilt facility to show the scrollbar. But Flutter has a widget for that, which is the “Scrollbar()” widget.

The Scrollbar widget is very simple to use. Simply wrap your Listview() with the Scrollbar widget and you are done.

Check the below code snippet.

Now the problem with the above code is it will not show scrollbar until you interact with the Listview.

To make a scrollbar to be seen always you have to change your code a bit.

  1. add the property: isAlwaysShown: true to the Scrollbar widget
  2. Create a ScrollController object and pass it to Scrollbar and ListView as well.

Check the code snippet below.

Here is the gist of the complete code snippet: https://gist.github.com/dhuma1981/a2c25929e9065e7fbb37f2b2b75cb8f3

Bonus:

The best part of the Scrollbar() widget is it internally checks whether there is a scroll available or not. And if the scroll is not required the scrollbar will not be shown :)

--

--

Dhrumil Shah
FlutterFlakes

Senior Mobile Application Developer at HighLevel | GDE for #Flutter & #Dart | Co-Organiser of #GDGAhmedabad | Founder of @Flutter_Flakes .