Slidable( key: Key(widget.galleryItemEntity.galleries[index].title), endActionPane: ActionPane( motion: const ScrollMotion(),//StretchMotion() children: [ SlidableAction( onPressed: (context){ widget.galleryItemEntity.galleries.removeAt(index); _refreshController.callRefresh(); setState(() {}); }, // padding: const EdgeInsets.only(bottom: 16), backgroundColor: Colors.red, foregroundColor: Colors.white, icon: Icons.delete_outline_outlined, ), ], ),设置左边删除显示区域的宽度
时间: 2024-02-10 13:31:15 浏览: 31
要设置`Slidable`左边删除显示区域的宽度,您可以使用`actionExtentRatio`属性来控制。`actionExtentRatio`属性指定了每个操作的宽度与滑动区域宽度的比例。
以下是一个示例代码,演示了如何使用`Slidable`并设置左边删除显示区域的宽度为原始宽度的一半:
```dart
Slidable(
key: Key(widget.galleryItemEntity.galleries[index].title),
endActionPane: ActionPane(
motion: const ScrollMotion(),
children: [
SlidableAction(
onPressed: (context) {
widget.galleryItemEntity.galleries.removeAt(index);
_refreshController.callRefresh();
setState(() {});
},
backgroundColor: Colors.red,
foregroundColor: Colors.white,
icon: Icons.delete_outline_outlined,
),
],
),
actionExtentRatio: 0.5, // 设置左边删除显示区域的宽度为原始宽度的一半
child: ListTile(
title: Text(widget.galleryItemEntity.galleries[index].title),
),
),
```
在这个示例中,我们将`actionExtentRatio`属性设置为`0.5`,表示左边删除显示区域的宽度为原始宽度的一半。
根据您的需求,您可以调整`actionExtentRatio`的值来设置左边删除显示区域的宽度。希望对您有帮助!