I need to disable the ListTile when at least one character is entered into the text field. I wrote the code, but I don’t understand how to write a function for onChanged. How can I do this?
bool _isEnableTile = true;
ListTile(
...
onTap: _isEnableTile
? () => _selectPosition(_positionsList![index].id)
: null,
);
TextField(
onChanged: _onChangedPosition,
),
void _onChangedPosition(text) {}
CodePudding user response:
Try This if you got any error let me know.
bool isAble=true;
ListTile(
title: const Text("Lable"),
enabled: isAble,
),
TextField(
onChanged: (value) {
if (value.length > 0) {
setState(() {
isaAble = false;
});
}
},
)