dart 更改列表的滚动条颜色

ru9i0ody  于 2022-12-15  发布在  其他
关注(0)|答案(1)|浏览(173)

我有一个列表视图构建器,它可以构建一些小部件,并将它们放在滚动条中:

我希望滚动条是紫色的,现在就是这样,问题是每次滚动时都得到The Scrollbar attempted to use the PrimaryScrollController. This ScrollController should be associated with the ScrollView that the Scrollbar is being applied to.A ScrollView with an Axis.vertical ScrollDirection on mobile platforms will automatically use the PrimaryScrollController if the user has not provided a ScrollController. To use the PrimaryScrollController explicitly, set ScrollView.primary to true for the Scrollable widget.,有没有方法可以创建类似的结果而不会得到这个错误?哪里出错了?
代码:

RawScrollbar(
               thumbColor: Colors.purple,
               child: ListView.separated(

                  // controller: c,
                      primary: false,
                      padding: EdgeInsets.only(left: 15.0, right: 15.0, top: 10.0),
                      separatorBuilder: (BuildContext context, int index) {
                        return Visibility(
                            visible: true,
                            child: Container(
                              height: height * margin,
                              width: width * .8,
                            ));
                      },
                      itemCount: _foundEvents.length,
                      itemBuilder: (context, index) => EventCard(
                        width: width * .8,
                        cardPadding: width * .05,
                        height: getCardHeight(height, margin: margin),
                        event: _foundEvents[index]["event"],
                        isLoading: eventsState.eventIdLoading ==
                            _foundEvents[index]["event"].id,
                      ),
                    ),
             )
qhhrdooz

qhhrdooz1#

为了RawScrollbar可以工作,它需要在主滚动列表上应用。但是现在您将ListView的primary设置为false。所以您需要将primary设置为true

相关问题