Hi, I’m new to the flutter and looking for a way to expand a widget so that when I click on it, I get a text field that allows me to input data from the user.
So far, I’ve tried dynamic test fields or gesture detectors, but I couldn’t find the answer I wanted, so I’m asking questions.
Is there any class that I can refer to?
2
Answers
You need to do few things…
create a variable
Wrap your widget with GestureDetector and use onTap of GestureDetector.
check the condition before your textField
The whole code is below and you can make some changes as per yours….
You can achieve this using the Visibility widget. Rohan’s answer is correct but I wouldn’t recommend using if statements in building widgets in a list since it makes the code look messy. I’ll put and example bellow:
When visibility’s value is true, it will display the content of its child property. Otherwise it will return a const SizedBox.shrink() by default. Or, you can change whatever widget you want to return adding the ‘replacement’ property.
Copy the code above and try on a new DartPad. Good Luck!