'Update Field with FieldPath, update doesn't accept FieldPath as parameter - Firebase Flutter
I was trying to delete a FieldValue inside Firebase, but the key had a "/" in it. So my app gave me this exception:
FirebaseException ([cloud_firestore/unknown] Use FieldPath.of() for field names containing '~*/[]'.)
After researching "FieldPath" for a while, I came up with following:
final CollectionReference userTodos = FirebaseFirestore.instance.collection('userTodos');
Future deleteToDo(String key, String listID) async {
return await userTodos
.doc(userID)
.collection('Lists')
.doc(listID)
.update(FieldPath([key]), FieldValue.delete());
}
But for some reason, it gives me this error:
The argument type 'FieldPath' can't be assigned to the parameter type 'Map<String, Object?>'
I don't understand why because here it says it accepts a String or FieldPath: https://firebase.google.com/docs/reference/js/v8/firebase.firestore.DocumentReference#update
Could someone help me please? Thanks :)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
