Make the text editable after press the button

1,502

I think this should do what you want.

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;
                    });
                  })
            ],
          ),
Share:
1,502
Tan Jiun Long
Author by

Tan Jiun Long

Updated on December 19, 2022

Comments

  • Tan Jiun Long
    Tan Jiun Long over 1 year

    Is anyone know how to make the text editable after I press the button? I want it to be editable only when the user clicks the button. Below is the result that I needed.

    enter image description here

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