I'm looking to write a document reference from a Flutter app to Firestore.
This is how it looks if I create a reference from the Firestore Console:

If I just write the references inside a String from Flutter
Map<String, String> usersReference = {
uid: 'users/' + uid
};
Map<String, Object> userData = {
'usersReference': usersReference
};
Firestore.instance.collection('chats').add(userData).then((doc) {
doc.setData(userData);
});
I get this:

Is there a way to write a reference (like from the Console) using the Flutter cloud_firestore plugin or any other SDK?
You should not declare an Object for the reference change it to DocumentReference
Map<String, DocumentReference> userData = {
'usersReference': usersReference
};
Firestore.instance.collection('chats').add(userData).then((doc) {
doc.setData(userData);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With