I have this simple widget showing a textfield from which I modify a List:
Widget _elementTextField() {
final TextEditingController inputNewElement = new TextEditingController();
return Expanded(
flex: 3,
child: Padding(
padding: EdgeInsets.fromLTRB(0, 16.0, 16.0, 16.0),
child: Container(
child: TextField(
controller: inputNewElement,
decoration: InputDecoration(labelText: "Add Element"),
onSubmitted: (elem) {
// method 1 to update UI
/*setState(() {
newSet.elements.add(elem);
});*/
// method 2 not updating UI
// newSet.elements.add(elem);
print(newSet.elements);
inputNewElement.clear();
},
),
),
),
);
}
If I uncomment any of those method I won't see the print and the input won't clean up.
This is not related to any other widget and the List is just a simple List with one value on it.
This works fine with other widget I have but on that case I modify the value on a global provider. This is using just a StateFul widget
class _NewSetPageState extends State<NewSetPage> {which is the main one and this loads_elementTextField()