我在 json 对象内编码了 Firestore DocumentReference。
"subscriber_document_reference" : "${subscriber.subscriberDocumentReference}"
解码后,我会得到带有字符串键和字符串值的映射。我想将此字符串更改为我可以使用的实际
DocumentReference
。
自然地,直接转换会失败,但有例外:
"type 'String' is not a subtype of type 'DocumentReference<Object?>' in type cast"
不确定你想做什么,但是 FirebaseFirestore.instance.collection('nameOfYourCollection').doc('yourString') 应该给出文档参考。
或者您的错误可能是由于您的 DocumentReference 未转换为字符串,因此无论您在何处解码,请使用 toString() 函数。