我有一个列表视图构建器,它可以构建一些小部件,并将它们放在滚动条中:
我希望滚动条是紫色的,现在就是这样,问题是每次滚动时都得到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,
),
),
)
1条答案
按热度按时间qhhrdooz1#
为了
RawScrollbar
可以工作,它需要在主滚动列表上应用。但是现在您将ListView的primary
设置为false
。所以您需要将primary
设置为true
。