最佳答案
ExpansionTile
立即关闭的原因是当您滚动浏览 listview
时,尤其是使用 ListView.builder
创建的列表再次重建,所以如果你想保留某个 ExpansionTile
的状态,你应该将它的状态值从你的 build
函数中保存下来,并使用 initiallyExpanded
属性:
List<bool> status = <bool>[] ; //store the statuses of your tiles here
ExpansionTile(
title: Text('Item'),
backgroundColor: Colors.transparent,
initiallyExpanded: status[index],
),
关于dart - Flutter:滚动时ExpansionTile强制关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55012712/