【发布时间】:2018-08-06 07:23:28
【问题描述】:
我有以下 Firestore 集合。
“用户”被添加为对“上传”文档的引用。
这是我使用的代码,当我没有那个“引用”对象时它可以正常工作。
return new StreamBuilder<QuerySnapshot>(
stream: Firestore.instance
.collection('uploads')
.where('type', isEqualTo: type)
.snapshots,
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
process(snapshot.data.documents);
});
但是当我添加这个用户引用时,我得到以下 Flutter 异常。
E/AndroidRuntime(11714): java.lang.IllegalArgumentException: Unsupported value: com.google.firebase.firestore.DocumentReference@147888c5
E/AndroidRuntime(11714): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:260)
E/AndroidRuntime(11714): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:257)
E/AndroidRuntime(11714): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:257)
E/AndroidRuntime(11714): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:249)
E/AndroidRuntime(11714): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:257)
E/AndroidRuntime(11714): at io.flutter.plugin.common.StandardMethodCodec.encodeMethodCall(StandardMethodCodec.java:31)
E/AndroidRuntime(11714): at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:82)
E/AndroidRuntime(11714): at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:69)
E/AndroidRuntime(11714): at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.onEvent(CloudFirestorePlugin.java:207)
E/AndroidRuntime(11714): at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.onEvent(CloudFirestorePlugin.java:190)
E/AndroidRuntime(11714): at com.google.firebase.firestore.zzi.onEvent(Unknown Source)
E/AndroidRuntime(11714): at com.google.android.gms.internal.zzevc.zza(Unknown Source)
E/AndroidRuntime(11714): at com.google.android.gms.internal.zzevd.run(Unknown Source)
E/AndroidRuntime(11714): at android.os.Handler.handleCallback(Handler.java:751)
E/AndroidRuntime(11714): at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime(11714): at android.os.Looper.loop(Looper.java:154)
E/AndroidRuntime(11714): at android.app.ActivityThread.main(ActivityThread.java:6176)
E/AndroidRuntime(11714): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(11714): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
E/AndroidRuntime(11714): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
当我将“引用”类型转换为其他类型时,它可以工作。
问题:
如何修改我的代码以获取上传内容及其用户参考详细信息?
【问题讨论】:
标签: firebase dart google-cloud-firestore flutter