當我拖動專案以對其進行重新排序時,我得到了一些奇怪的空白區域,這是無處定義的。如何擺脫白色間距并擴展卡片以填充該空間?這就是重新排序專案時白色間距的樣子:

這就是我構建腳手架主體的代碼:
body:
Stack(
children: [
Positioned(
child: ReorderableListView.builder(
buildDefaultDragHandles: false,
itemCount: widget.cards.length,
itemBuilder: (context, index) {
return Dismissible(
key: Key(widget.cards[index].name),
onDismissed: (direction) {
setState(() {});
},
child:
Card(
child:
SizedBox(
height: 75,
child: ListTile(
tileColor: Colors.red.shade200,
title: Text(widget.cards[index].name),
trailing: ReorderableDragStartListener(
index: index,
child: const Icon(Icons.drag_handle),
),
onTap: (){
},
),
),
),
);
},
),
)
])
uj5u.com熱心網友回復:
在您的情況下,卡片小部件默認邊距出現填充。您可以使用此代碼洗掉。如果您洗掉它,則不會顯示Card Widget的高度。如果您不想這樣做,您可以洗掉Card Widget。
Card(
margin: EdgeInsets.all(0),
child: SizedBox( .......
uj5u.com熱心網友回復:
用于proxyDecorator在重新排序時提供您的自定義小部件
結果
Stack(children: [
Positioned(
child: ReorderableListView.builder(
padding: EdgeInsets.zero,
proxyDecorator: (child, i, d) { // Here
return Card(
child: SizedBox(
height: 75,
child: ListTile(
selectedTileColor: Colors.amber,
tileColor: Colors.red.shade200,
title: Text(cards[i]),
trailing: ReorderableDragStartListener(
index: i,
child: const Icon(Icons.drag_handle),
),
onTap: () {},
),
),
);
},
onReorder: (oldIndex, newIndex) {},
buildDefaultDragHandles: false,
itemCount: cards.length,
itemBuilder: (context, index) {
return Dismissible(
key: Key(cards[index]),
onDismissed: (direction) {
setState(() {});
},
child: Card(
child: SizedBox(
height: 75,
child: ListTile(
selectedTileColor: Colors.amber,
tileColor: Colors.red.shade200,
title: Text(cards[index]),
trailing: ReorderableDragStartListener(
index: index,
child: const Icon(Icons.drag_handle),
),
onTap: () {},
),
),
),
);
},
),
)
]);
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/522867.html
標籤:安卓IOS扑
