我有一个 ListView
,它通常从顶部开始并且可以向下滚动,但是我将 reverse
设置为 true
我需要它,但现在列表从底部开始。
如何设置开始位置,使其从顶部开始并向下滚动,尽管已反转?
所以基本上是这样的,日期顺序按照我的需要颠倒过来:
14th
12th
7th
6th
5th
但默认情况下整个内容都滚动到底部...所以除非我向上滚动,否则我看不到第 12 和第 14。
....off the top of the screen
7th
6th
5th
4th
3rd - starting position.
我需要它通过设置滚动开始位置从滚动到顶部开始。我希望这个描述能让它更清楚一些。
最佳答案
您也可以用这种方式颠倒呈现顺序:注意 ((feed.length-1) - index)
数组索引。将此技术与您正在使用的技术结合使用将产生您想要的结果。
List<String> feed = List();
feed.add("AAAA");
feed.add("BBBB");
feed.add("CCCC");
ListView.builder(
itemCount: feed.length,
itemBuilder: (context, index) {
return ListTile(title: feed[(feed.length - 1) - index]);
},
);
关于listview - Flutter 反转 ListView 从顶部开始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57499254/