[英]flutter: how to add a scroll bar in the right of the ListView?
I'm working with flutter.我正在处理颤振。 I want to add a scroll bar to the right of the
ListView
just similar to the net page scroll bar, but I haven't found any related property.我想在
ListView
的右侧添加一个类似于网页滚动条的滚动条,但我还没有找到任何相关的属性。 Is this possible?这可能吗? The basic code is ready for your advice.
基本代码已准备好接受您的建议。
ListView(
scrollDirection: Axis.vertical,
children: <Widget>[
// I will put some HTML code here,
],
),
There are packages available if you want custom scrollbar or you can use flutter inbuilt scrollbar widget too draggable_scrollbar如果您想要自定义滚动条,或者您也可以使用 flutter 内置滚动条小部件,则有可用的软件包draggable_scrollbar
I think better to use CupertinoScrollbar
instead of Scrollbar.我认为最好使用
CupertinoScrollbar
而不是 Scrollbar。 CupertinoScrollbar
is can touch and scroll to the bottom CupertinoScrollbar
可以触摸并滚动到底部
Ex:前任:
CupertinoScrollbar(
isAlwaysShown: true,
controller: _scrollController,
child: ListView.builder(
controller: _scrollController,
itemCount: 100,
itemBuilder: (context, index) {
return Card(
child: ListTile(
title: Text("Item: ${index + 1}"),
));
}),
),
Or You can use Scrollbar
或者您可以使用
Scrollbar
final ScrollController _scrollController = ScrollController();
Scrollbar(
isAlwaysShown: true,
controller: _scrollController,
child: ListView.builder(
controller: _scrollController,
itemCount: 100,
itemBuilder: (context, index) {
return Card(
child: ListTile(
title: Text("Item: ${index + 1}"),
));
}),
),
You can wrap Listview
with the ScrollBar
widget.您可以使用
ScrollBar
小部件包装Listview
。
ScrollBar(
isAlwaysShown: true, // optionel
child: ListView(
scrollDirection: Axis.vertical,
children: <Widget>[
// I will put some HTML code here,
],
),
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.