I'm trying to update only one field in the document but the other field is set to null if I didn't give them a value.
this is my code
Future updateUser({
String? uid,
String? displayName,
String? email,
String? phoneNumber,
String? photoURL,
String? creationTime,
}) async {
return await usersCollection.doc(uid).update({
"id": uid,
"displayName": displayName,
"email": email,
"phoneNumber": phoneNumber,
"photoURL": photoURL,
"type": 'Not Admin',
"isApproved": false,
"creationTime": creationTime,
});
}
Can I update a single field without creating a method for every field I want to update?
so if I want to update displayName I just pass displayName to the method and leave other fields without change.
please help me to find a better way to do that