在按下按钮(颤振)后使文本可编辑

问题描述 投票:0回答:1

有人在按下按钮后知道如何使文本可编辑吗?我希望仅当用户单击按钮时才可以对其进行编辑。以下是我需要的结果。

If I want to edit the text "Festive Leave", then I need to click the edit button

flutter flutter-layout textfield floating-action-button
1个回答
0
投票

我认为这应该做您想要的。

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;
                    });
                  })
            ],
          ),
© www.soinside.com 2019 - 2024. All rights reserved.