【发布时间】:2019-06-08 03:06:46
【问题描述】:
我正在尝试在文档中创建子集合并将数据设置为创建的子集合中的文档。
我已经尝试过了,但每次运行时程序都会崩溃。
await Firestore.instance
.collection('/path')
.document("documentPath")
.collection('/subCollectionPath')
.document()
.setData({
'TestData': "Data",
}).then((onValue) {
print('Created it in sub collection');
}).catchError((e) {
print('======Error======== ' + e);
});
我也上网查了,但找不到任何文档。
有什么想法吗?
当我尝试上面的代码时,应用程序崩溃并显示以下消息
flutter: EVENT StorageTaskEventType.success
*** First throw call stack:
(
0 CoreFoundation 0x0000000111eb61bb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000111454735 objc_exception_throw + 48
2 Runner 0x000000010ce707b1 -[FIRFirestore documentWithPath:] + 257
3 Runner 0x000000010d10662c getDocumentReference + 124
4 Runner 0x000000010d109879 -[FLTCloudFirestorePlugin handleMethodCall:result:] + 2665
5 Flutter 0x000000010e5b99a2 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 115
6 Flutter 0x000000010e5d6616 _ZNK5shell21PlatformMessageRouter21HandlePlatformMessageEN3fml6RefPtrIN5blink15PlatformMessageEEE + 166
7<…>
与设备的连接丢失。
【问题讨论】:
-
试试 -
Firestore.instance .collection('/path') .document("documentPath") .collection('/subCollectionPath').reference() .document() .setData({ 'TestData': "Data", }).then((onValue) { print('Created it in sub collection'); }).catchError((e) { print('======Error======== ' + e); }); -
那行不通。同样的事情也发生了。应用崩溃了。
-
我编辑了问题以添加消息。见上面的问题。
标签: firebase dart flutter google-cloud-firestore