Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Scrollbar colour in flutter?

I have a normal ListView which is wrapped by the Scrollbar class to produce a scrollbar when scrolling down. But I want to change the Scrollbar color to white since I have a dark background.

After exploring the Scrollbar class I can see that it uses the theme highlightColor as shown inside scrollbar.dart.

_themeColor = theme.highlightColor.withOpacity(1.0);

Tried wrapping the Scrollbar in a Theme but still no luck.

Below is my code -

Theme(
  data: ThemeData(
    highlightColor: Colors.white, //Does not work
  ),
  child: Scrollbar(
    child: ListView(
      //Normal ListView code
    ),
  ),
)

Any help is appreciated. Thanks in advance.

like image 493
thedarthcoder Avatar asked Apr 18 '19 10:04

thedarthcoder


People also ask

Can you change the color of the scrollbar?

However, it is still possible to adjust the scrollbar colour in Windows 10, but you have to do the change via Registry: Open the Registry Editor. There you have to change the Scrollbar value to any colour you like. The defaults are: "200 200 200" and "212 208 200", respectively.

How do you add a vertical scroll bar in flutter?

What you'll have to do is nest the vertical and horizontal SingleChildScrollView and wrap it with two ScrollBar then attach a ScrollController respectively and use the notificationPredicate property on the inner ScrollBar.


1 Answers

You can use RawScrollbar instead and set the thumbColor to whatever color u like.

child: RawScrollbar(
                    thumbColor: Colors.redAccent,
                    radius: Radius.circular(20),
                    thickness: 5,
                    child: //scrollable widget
                   )
like image 149
MTs Avatar answered Oct 05 '22 22:10

MTs