![](/img/trans.png)
[英]Remove top padding in ListView put inside scaffold with no appBar
[英]items in listview are not placed at the top of the scaffold container
問題是這些項目沒有像我預期的那樣位於 position 0 的頂部。
我已經嘗試將搜索欄放置在滾動視圖的頂部額外空間上,但是當您開始滾動時,卡片與搜索欄小部件重疊。
所以我的問題是:是什么導致了這個額外的空間,我該如何刪除它?
滾動列表 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];
}
)
)
);
}
}
從ListView
的文檔:
默認情況下,ListView 將自動填充列表的可滾動末端,以避免 MediaQuery 的填充指示的部分障礙。 要避免此行為,請使用零填充屬性覆蓋。
所以嘗試將其添加到ListView
構造函數中:
padding: EdgeInsets.zero,
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.