标签: flutter-scrollbar

无法将 ScrollBar 添加到 ScrollablePositionedList (它没有 ScrollController)

我正在使用scrollable_positioned_list包,并让它渲染一个大的动态列表。它运作得很好。但是,我需要我的列表有一个滚动条(类似这样)。到目前为止,这是不可能的。

\n

有谁知道该怎么做?

\n

我的代码如下所示:

\n
Scrollbar(\n          child: ScrollablePositionedList.builder(\n            physics: const ClampingScrollPhysics(\n              parent: AlwaysScrollableScrollPhysics(),\n            ),\n            itemCount: posts.length + 1,\n            itemBuilder: (context, index) {\n              if (index == 0) {\n                return Container(\n                  height: 200,\n                  color: Colors.green,\n                  child: const Center(\n                    child: Text(\'post content\'),\n                  ),\n                );\n              } else if (posts[index - 1].isRoot) {\n                return Container(\n                  padding: const EdgeInsets.symmetric(vertical: 15),\n                  margin: const EdgeInsets.symmetric(vertical: 5),\n                  color: Colors.redAccent,\n                  child: Text(\'ROOT COMMENT, index: ${index - 1}\'),\n                );\n              } else {\n                return Container(\n                  padding: const …
Run Code Online (Sandbox Code Playgroud)

dart flutter flutter-layout flutter-listview flutter-scrollbar

5
推荐指数
2
解决办法
1732
查看次数