我在我的第一個串列視圖項上有這個“額外空間”,它是封裝在容器中的卡片。如何洗掉它?

Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.all(15.0),
height: 300,
child: Column(children: [
Row(children: [
Expanded(
child: Text("Lowest Fuel Price",
style: TextStyle(
fontWeight: FontWeight.w500,
color: Theme.orange3,
fontSize: 16.0)))
]),
Container(
height: 250,
child: Card(
elevation: 3,
child: ListView.builder(
itemCount: cheapest.length,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
final item = cheapest[index];
return Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Text(
item.petrolType,
style: TextStyle(
color: Theme.gray1, fontSize: 18),
),
Text(
"\$" item.petrolPrice,
style: TextStyle(
color: Theme.gray1, fontSize: 25),
),
Image(
fit: BoxFit.fill,
image: new AssetImage(
'assets/images/fuel_station/'
item.petrolStation.toLowerCase()
'.png')),
]),
index != cheapest.length - 1
? Divider(
color: Colors.grey,
)
: Divider(color: Colors.white)
],
);
})),
)
]));
}
uj5u.com熱心網友回復:
https://api.flutter.dev/flutter/widgets/ListView-class.html
默認情況下,ListView 將自動填充串列的可滾動末端以避免由 MediaQuery 的填充指示的部分障礙。為避免這種行為,請使用零填充屬性進行覆寫。
Card(
elevation: 3,
child: MediaQuery.removePadding(
context: context,
removeTop: true,
child: ListView.builder(),
),
),
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/317321.html
上一篇:型別錯誤:無法使用動態創建的qml串列模型在嵌套串列視圖中讀取null的屬性“newdaycalendar”
下一篇:XamarinListView系結似乎在更新的VS201916.11.3中被破壞了。CollectionView系結也是如此。有人可以調查一下嗎?
