nick coder
nick coder

Reputation: 159

flutter preserve the value in showModalBottomSheet when reopen

I have a textField in showModalBottomSheet. What i want if user fill the value in textField and close the bottom sheet and reopen it the value must not be lost. The same value in textField must be shown. How can i preserve the value in modal bottom Sheet?

Upvotes: 0

Views: 177

Answers (1)

Xuuan Thuc
Xuuan Thuc

Reputation: 2521

  1. create variable for value: _value

  2. set new value for _value on onTextChanged()

  3. When open bottom sheet, init value for textField

    TextEditingController _controller = TextEditingController(text: _value)

Upvotes: 1

Related Questions