thumbVisibility property

bool? thumbVisibility
final

Indicates that the scrollbar thumb should be visible, even when a scroll is not underway.

When false, the scrollbar will be shown during scrolling and will fade out otherwise.

When true, the scrollbar will always be visible and never fade out. This requires that the Scrollbar can access the ScrollController of the associated Scrollable widget. This can either be the provided controller, or the PrimaryScrollController of the current context.

Defaults to false when null.

link
// (e.g. in a stateful widget)

final ScrollController controllerOne = ScrollController();
final ScrollController controllerTwo = ScrollController();

@override
Widget build(BuildContext context) {
return Column(
  children: <Widget>[
    SizedBox(
       height: 200,
       child: Scrollbar(
         thumbVisibility: true,
         controller: controllerOne,
         child: ListView.builder(
           controller: controllerOne,
           itemCount: 120,
           itemBuilder: (BuildContext context, int index) {
             return Text('item $index');
           },
         ),
       ),
     ),
     SizedBox(
       height: 200,
       child: CupertinoScrollbar(
         thumbVisibility: true,
         controller: controllerTwo,
         child: SingleChildScrollView(
           controller: controllerTwo,
           child: const SizedBox(
             height: 2000,
             width: 500,
             child: Placeholder(),
           ),
         ),
       ),
     ),
   ],
  );
}

See also:

If this property is null, then ScrollbarThemeData.thumbVisibility of ThemeData.scrollbarTheme is used. If that is also null, the default value is false.

If the thumb visibility is related to the scrollbar's material state, use the global ScrollbarThemeData.thumbVisibility or override the sub-tree's theme data.

Implementation

final bool? thumbVisibility;