所以我有一个ListTiles的ListView,每个图块都有一个复选框。我可以很好地更改复选框的状态,但是不会显示正确的动画。我在这里想念什么?谢谢!
Widget _buildListTile(BuildContext context, Task item) {
return Dismissible(
// Show a red background as the item is swiped away
background: Container(color: Colors.red),
key: Key(item.hashCode.toString()),
onDismissed: (direction) {
setState(() {
tasks.remove(item);
});
},
child: ListTile(
leading: Checkbox(
value: item.checked,
onChanged: (bool newValue) {
setState(() {
item.checked = newValue;
});
},
activeColor: Colors.blue,
),
title: InkWell(
onTap: () {
editTask(item);
},
child: Text(
item.task,
style: TextStyle(fontSize: 18),
)),
contentPadding: EdgeInsets.all(8),
//trailing: Icon(Icons.drag_handle),
),
);
}