我在SliverList中使用flutter Slidable小部件,其中的列表元素是从数组中拉出的。我使用setState来更新列表。
我遇到的问题是,在列表更新之后,我可以正确地看到所有新元素,但滑动功能不起作用。但是,在使用push进入新页面并使用pop离开后,可滑动功能开始工作。
为什么会发生这种情况?
return SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) => Card(
child: InkWell(
child: Slidable(
key: Key(_fileList[index].key),
actionPane: SlidableDrawerActionPane(),
child: Container(
child: ListTile(
onTap: () {
...
},
title: Text(_fileList[index].subtitle),
subtitle: Text(_fileList[index].subtitle),
),
),
secondaryActions: <Widget>[
IconSlideAction(
caption: 'Delete',
color: Colors.red,
icon: Icons.delete,
onTap: () {
...
}
),
],
),
),
),
childCount: _fileList.length,
),
);更新过程如下所示:
setState(() {
_fileList = newFileList;
});发布于 2021-03-09 08:59:38
没关系,我不小心禁用了SlidableController,然后又重新启用了它。
https://stackoverflow.com/questions/58150425
复制相似问题