有人在按下按钮后知道如何使文本可编辑吗?我希望仅当用户单击按钮时才可以对其进行编辑。以下是我需要的结果。
If I want to edit the text "Festive Leave", then I need to click the edit button
我认为这应该做您想要的。
TextEditingController _controller =
TextEditingController(text: "Festive Leave");
bool _isEnable = false;
//These are initialize at the top
Row(
children: <Widget>[
Container(
width: 100,
child: TextField(
controller: _controller,
enabled: _isEnable,
),
),
IconButton(
icon: Icon(Icons.edit),
onPressed: () {
setState(() {
_isEnable = true;
});
})
],
),