问题
I'm using this code from here
Firestore.instance.collection('path').document('name').updateData({'Desc': FieldValue.delete()}).whenComplete((){
print('Field Deleted');
});
I'm using
cloud_firestore: 0.13.2+1
However, this throws an error
[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: type 'MethodChannelFieldValue' is not a subtype of type 'FieldValuePlatform'
Can anyone tell me how to delete a field right way
回答1:
You may refer to the official Firestore documentation for guidance on how to delete fields.
var cityRef = db.collection('cities').doc('BJ');
// Remove the 'capital' field from the document
var removeCapital = cityRef.update({
capital: firebase.firestore.FieldValue.delete()
});
来源:https://stackoverflow.com/questions/60759410/error-in-deleting-specific-field-in-a-cloud-firestore-document