📜  清除文本字段飞镖 - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:12.857000             🧑  作者: Mango

代码示例3
//To clear a textField, use a TextEditing Controller
final _controller = TextEditingController();

            Column(
            children: [
              TextField(
                  decoration: InputDecoration(labelText: 'Title'),
                  controller: _controller,
                  onChanged: (value) {
                    titleInput = value;
                  }),
                ElevatedButton(
                  onPressed: () => _controller.clear(),
                  child: Text('Add Transaction!'),
              ),
            ],
          ),