[英]items in listview are not placed at the top of the scaffold container
I am building a dynamic scroll view.我正在构建一个动态滚动视图。 The current result is this one.
目前的结果是这样的。
The problem is that the items are not positioned on top at position 0, as I intended.问题是这些项目没有像我预期的那样位于 position 0 的顶部。
I tried already placing the searchbar over the top extra space of the scroll view, but when you start scrolling, the cards are overlapping the searchbar widget.我已经尝试将搜索栏放置在滚动视图的顶部额外空间上,但是当您开始滚动时,卡片与搜索栏小部件重叠。
So my question is: what is causing this extra space, and how can I remove it?所以我的问题是:是什么导致了这个额外的空间,我该如何删除它?
ScrollList class:滚动列表 class:
class ScrollListWidget extends DersObject {
late ListHandler listHandler;
int cardsPerScreen;
double margin;
double getCardHeight(){
return this.height / this.cardsPerScreen - heightPercentageAsDouble(this.margin) * 2;
}
ScrollListWidget(width, height, listType, {this.cardsPerScreen = 3, this.margin = 0.01}): super(width: width, height: height){
this.listHandler = ListHandler(width, getCardHeight(), listType);
}
@override
Widget build(BuildContext context) {
return Container(
width: width,
height: height,
child: new Scaffold(
body: new ListView.separated
(
separatorBuilder: (BuildContext context, int index) {
return Line(height: heightPercentageAsDouble(this.margin), width: width,
color: Color.fromARGB(255, 255, 255, 255));
},
itemCount: listHandler.getList().length,
itemBuilder: (BuildContext ctxt, int index) {
return listHandler.getList()[index];
}
)
)
);
}
}
From documentation of ListView
:从
ListView
的文档:
By default, ListView will automatically pad the list's scrollable extremities to avoid partial obstructions indicated by MediaQuery's padding.
默认情况下,ListView 将自动填充列表的可滚动末端,以避免 MediaQuery 的填充指示的部分障碍。 To avoid this behavior, override with a zero padding property.
要避免此行为,请使用零填充属性覆盖。
So try to add this to the ListView
constructor:所以尝试将其添加到
ListView
构造函数中:
padding: EdgeInsets.zero,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.