首页 > 解决方案 > 如何在颤动中设置滚动条颜色?

问题描述

我有一个ListViewScrollbar类包装的法线,以在向下滚动时产生滚动条。但是我想将Scrollbar颜色更改为白色,因为我有深色背景。

在探索Scrollbar课程后,我可以看到它使用了highlightColor里面所示的主题scrollbar.dart

_themeColor = theme.highlightColor.withOpacity(1.0);

尝试将其包裹起来ScrollbarTheme但仍然没有运气。

下面是我的代码 -

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

任何帮助表示赞赏。提前致谢。

标签: androiddartflutterflutter-layout

解决方案


您可以改用 RawScrollbar 并将 thumbColor 设置为您喜欢的任何颜色。

child: RawScrollbar(
                    thumbColor: Colors.redAccent,
                    radius: Radius.circular(20),
                    thickness: 5,
                    child: //scrollable widget
                   )

推荐阅读