显示黑屏 - 见评论。
也给出错误:
在 performResize() 期间抛出了以下断言:
_RenderTheatre 对象在布局期间被赋予无限大小。
还有这个错误:
BoxConstraints 强制无限高。
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(slivers: [
SliverToBoxAdapter(
child: ReorderableListView(
onReorder: (oldIndex, newIndex) {
setState(() {
if (newIndex > oldIndex) {
newIndex -= 1;
}
final Todo item = TodoList.myTodos.removeAt(oldIndex);
TodoList.myTodos.insert(newIndex, item);
});
},
children: [
for (final todo in TodoList.myTodos)
Dismissible(
onDismissed: (direction) {
if (direction == DismissDirection.startToEnd && todo.done == false) {
// Mark todo as done
todo.done = true;
TodoList.myTodos.add(Todo(todo.title, todo.done = true,
todo.oldIndex = TodoList.myTodos.indexOf(todo)));
TodoList.myTodos.remove(todo);
debugPrint("Todo ${todo.title} marked as done");
} else if (direction == DismissDirection.startToEnd && todo.done == true) {
todo.done = false;
TodoList.myTodos.insert(todo.oldIndex, Todo(todo.title, todo.done = false));
TodoList.myTodos.remove(todo);
debugPrint("Todo ${todo.title} marked as undone");
} else if (direction == DismissDirection.endToStart) {
TodoList.myTodos.remove(todo);
debugPrint("Todo ${todo.title} deleted");
}
setState(() {});
},
key: todo.key,
background: Container(
color: Colors.green,
child: Icon(Icons.check),
),
secondaryBackground: Container(
color: Colors.red,
child: Icon(Icons.delete),
),
child: ListTile(
tileColor: calculateColor(todo),
key: todo.key,
title: TextField(
// TODO fix long press to drag todo instead of selecting the textfield. Short tap should be to select textfield!
// TODO Add app theme to textfield
style: (todo.done ? TextStyle(decoration: TextDecoration.lineThrough) : null),
controller: TextEditingController(text: todo.title),
decoration: null,
maxLength: 512,
maxLines: null,
textInputAction: TextInputAction.done,
onChanged: (text) {
//TODO check if correct
todo.title = text;
},
onEditingComplete: () {
//TODO check if correct
FocusScopeNode currentFocus = FocusScope.of(context);
currentFocus.unfocus();
},
onSubmitted: (text) {
//TODO check if correct
todo.title = text;
FocusScopeNode currentFocus = FocusScope.of(context);
currentFocus.unfocus();
},
),
),
)
],
),
)
]),
);
}