Make sure your TextField
is part of a StatefulWidget
and you need to change the value of newTaskName
using setState
like this.
TextField(
autofocus: true,
onChanged: (newText) {
setState(() {
newTaskName = newText;
});
},
)