gpt4 book ai didi

flutter - 如何在左上方对齐 ListView 项?

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

我试图在左上方对齐列表 View 项目,但它在中心对齐它们。我尝试了另一个小部件,它工作正常,但使用listview却没有。
这是我的代码

 Container(
height: height * 30,
// color: Colors.grey[400],
alignment: Alignment.topLeft,
child: ListView.builder(
itemBuilder: (context, i) => ReviewItem(
review: book.reviews[i]['review'],
date: book.reviews[i]['date'],
),
itemCount: book.reviews.length,
),
),

这是评论项目
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
timeago.format(DateTime.parse(date)),
style: Theme.of(context).textTheme.headline4.copyWith(
fontSize: width * kFont12Ratio, color: Colors.grey[500]),
),
SizedBox(height: height * 0.5),
Text(review),
Divider(),
],
);

this is what i am getting
this is what I am expecting
提前致谢

最佳答案

默认情况下,ListView将自动填充列表的可滚动末端,以避免MediaQuery的填充指示部分障碍。换句话说,如果将小部件放置在ListView之前,则应使用MediaQuery.removePadding小部件(带有removeTop: true)包装ListView。像这样:

MediaQuery.removePadding(
context: context,
removeTop: true,
child: ListView.builder(...),
);

关于flutter - 如何在左上方对齐 ListView 项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63430733/

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