I've been trying to create a demo "Schedule-App" powered by Google's Firebase, but I'm facing some difficulties updating specific values of an Array with Map values on the side of Firestore.
As you can see on the following image, what we want to achieve is onButtonPress, this specific value to be updated.
I've created a Stream of data and manage it via StreamProvider.
StreamProvider<DocumentSnapshot>.value( value: FirebaseFirestore.instance.collection('schedule').doc(FirebaseAuth.instance.currentUser.uid).snapshots(), I'm using the following method to update Array's data, but it doesn't work.
Future<void> updateUserData(int index, String title, String text, int hour, bool check) async { DocumentReference snapshots = FirebaseFirestore.instance.collection('schedule').doc(FirebaseAuth.instance.currentUser.uid); snapshots.update({ ['standard_schedule'][index]: {'title': title, 'text': text, 'hour': hour, 'check': check} }); } What changes should I make to the method above, so that the bool value to be updated, every time the button is pressed?
===============================================
SOLUTION (10/24/2020): Firestore does not provide a way to update an array element at an index. You have to read the entire document, modify the array in memory, then write the entire array back to the document.
