1. List通过Map转换为组件
ListView(
children: db.todoList
.map<Widget>(
    (e) => TodoTile(e.isComplete, e.title, () => onTap(e), () => onDelete(e)))
.toList()),
  1. 输入框的使用
// 定义输入框控制器
final TextEditingController _controller = TextEditingController();

//  输入框UI
TextField(decoration: InputDecoration(labelText: "请输入任务"), controller: _controller, ),

// _controller.text获取输入框内容
var newTask = TodoModel(false, _controller.text);
// 清空输入框
_controller.clear();
  1. 对话框的使用
show_dialog() {
  showDialog(
    context: context,
    builder: (builder) {
      return AlertDialog(
        title: Text("add task"),
        content: TextField(
          decoration: InputDecoration(labelText: "请输入任务"),
          controller: _controller,
        ),
        actions: <Widget>[
          MaterialButton(onPressed: cancel, child: Text("取消")),
          MaterialButton(onPressed: save, child: Text("确定")),
        ],
      );
    },
  );
}

void save() {
  var newTask = TodoModel(false, _controller.text);
  _controller.clear();

  setState(() {
    db.todoList.add(newTask);
  });
  Navigator.of(context).pop();
}

void cancel() {
  Navigator.of(context).pop();
}