I am trying to develop a stock management application on Flutter. I have integrated Firebase into the app and I can view the data on the app. My collection and documents are as follows:
I want to add a new element to an array in an already existing document wtih this.
Map<String, dynamic> urunData = {
'ad': _adController.text,
'kod': _barcodeController.text,
'seri': _seriController.text,
'raflar': [
{'raf': dropdownValue, 'adet': _rafController.text},
],
'sirket': _sirketController.text,
'tarih': FieldValue.serverTimestamp()
};
sayimRef.doc(_barcodeController.text).update(urunData);
But in this way, the other elements in the 'raflar' array inside document are deleted and it is transformed into a new array with one element. How do I update an existing index or add a new one without deleting other elements?