Flutter 如何使扑动中的卡片可拖动
我的任务列表存储在“待办事项”类型列表中。我想迭代列表,为每个项目创建一张卡片,并且我想能够在长按时拖动和重新排序这些卡片 以下是我如何获得今天的任务:Flutter 如何使扑动中的卡片可拖动,flutter,Flutter,我的任务列表存储在“待办事项”类型列表中。我想迭代列表,为每个项目创建一张卡片,并且我想能够在长按时拖动和重新排序这些卡片 以下是我如何获得今天的任务: List<Todo> todayTasks = []; for (var i = 0; i < _todos.length; i++) { if (_todos[i].deadline != null) { if (_todos[i].deadline.substring(0,
List<Todo> todayTasks = [];
for (var i = 0; i < _todos.length; i++) {
if (_todos[i].deadline != null) {
if (_todos[i].deadline.substring(0, 11) ==
todayDate.toString().substring(0, 11)) {
todayTasks.add(_todos[i]);
}
}
}
我有两件事要告诉你,你可以通过这两件事得到你想要的结果:
- 你能做的最好的事情就是使用它,它是可以生长的。因此,您可以将项目添加到列表中
- 你可以选择的另一个聪明的方法是使用软件包,这会使你的工作更容易。有一个包裹是给你的,名为
请使用这些指针,您就可以开始了:)这是否回答了您的问题?
for (var todo in todayTasks)
new Card(
shadowColor: Colors.black,
child: ListTile(
onTap: () => model.updateTodo(
todo.copy(isCompleted: todo.isCompleted == 1 ? 0 : 1)),
contentPadding:
EdgeInsets.symmetric(horizontal: 0, vertical: 8.0),
leading: CircularCheckBox(
onChanged: (value) =>
model.updateTodo(todo.copy(isCompleted: value ? 1 : 0)),
value: todo.isCompleted == 1 ? true : false,
materialTapTargetSize: MaterialTapTargetSize.padded,
),
trailing: IconButton(
icon: Icon(Icons.delete_outline),
onPressed: () => model.removeTodo(todo),
),
title: Text(
todo.name,
style: TextStyle(
fontSize: 18.0,
fontFamily: 'Roboto',
fontWeight: FontWeight.w600,
color: todo.isCompleted == 1
? Colors.grey[500]
: Colors.black,
decoration: todo.isCompleted == 1
? TextDecoration.lineThrough
: TextDecoration.none,
),
),
),
),