【发布时间】:2021-04-08 17:28:37
【问题描述】:
在我的 Flutter 项目中,我有一个表单,用户可以在其中填写详细信息并上传图片。当按下“提交”按钮时,带有以下信息的文档将存储在“产品”集合中,即 Firestore。但是,由于用户能够上传多个图像,我希望将imageUrl 存储为“图像”数组中的字符串元素,而不是“图像”的绝对字符串值,但我不知道该怎么做。目前负责上传上述数据的代码如下:
Future<void> addProduct() {
// Call the user's CollectionReference to add a new product
return _firebaseAuthServices.productsReference
.add({
'name': nameController.text,
'size': sizeController.text,
'price': priceController.text,
'description': descController.text,
'images': imageUrl,
})
.then((value) => print("Product Added"))
.catchError((error) => print("Failed to add product: $error"));
}
如何将imageUrl 的值存储为“图像”数组的元素?
【问题讨论】:
-
问题到底出在哪里?你是不是故意使用_authservices?
-
我编辑了这个问题,使其更加清晰和有凝聚力! _firebaseAuthServices 对存储数据的集合的引用
-
将
imageUrl添加为动态列表
标签: java android firebase flutter dart