gpt4 book ai didi

android - 如何在Flutter中打印列表后防止自动向下滚动

转载 作者:行者123 更新时间:2023-12-03 03:50:04 29 4
gpt4 key购买 nike

我是个新手。所以最近我正在使用ListView Builders。因此,我在屏幕上打印了整个数据列表,但在完成列表打印后,我希望屏幕焦点停留在顶部而不是底部。
基本上,我只想停留在屏幕顶部。
这是我的listView.builder代码

return ListView.builder(
shrinkWrap: true,
reverse: true,
itemCount: snapshot.data.length,
itemBuilder: (context, index) {
return SingleChildScrollView(
child: Container(
height: null,
margin: const EdgeInsets.symmetric(
horizontal: 20, vertical: 10),
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(20.0)),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(100),
blurRadius: 10.0),
]),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20.0, vertical: 10),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(
0.0, 0.0, 10.0, 0.0),
child: Text(
snapshot.data[index].data()["date"],
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(
0.0, 0.0, 10.0, 0.0),
child: Text(
snapshot.data[index].data()["notice"],
style: const TextStyle(
fontSize: 19.0,
fontWeight: FontWeight.bold),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(
5.0, 10.0, 5.0, 10.0),
child: Text(
snapshot.data[index].data()["actual"],
style: GoogleFonts.roboto(
fontSize: 15.5,
fontWeight: FontWeight.w400),
),
),
]))));
});
我希望你理解我的问题。
谢谢!

最佳答案

好,最后我做到了。多亏了@scottgodfrey的帮助,我有了将反向设置为false的想法,之后我用document-1的长度更新了索引,因此,我能够以反向方式打印数据,而无需一一打印而且不使用反向链接,而反向链接曾经使我的屏幕跌至最底部!

关于android - 如何在Flutter中打印列表后防止自动向下滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63766359/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com