Reputation: 253
I have a button which is create a new data for firebase. But when i change the data its updating , but i want to add a new one. For example , this is my set part;
IconButton(
onPressed: () {
_firestore.collection("UsersTodos").doc(username).set({
'userTodo': [_todoController.text],
});
},
icon: Icon(Icons.add)),
When i enter another value to textfield my document is updating and change the value, i need to create an another value for that document.
Shall i loop this area with for loop ?
Upvotes: 0
Views: 406
Reputation: 408
Try this code, it should add items to list:
_firestore.collection("UsersTodos").doc(username).update({
'userTodo': FieldValue.arrayUnion([_todoController.text]),
});
Upvotes: 2