我用了這個方法,我得到了兩個錯誤。
第一個錯誤:
A value of type 'Future<String>' can't be assigned to a variable of type 'List<dynamic>'. Try changing the type of the variable, or casting the right-hand type to 'List<dynamic>'.
當我使用這種方法時:
List newPhotoUrl = StroageMethods().uploadImageToStroage('Posts', file, true);
其次,我是這樣寫的。
try {
List newPhotoUrl =
StroageMethods().uploadImageToStroage('Posts', file, true);
String postid = _firestore.collection('Posts').doc().id;
Post post = Post(
postImages: FieldValue.arrayUnion([{'0': newPhotoUrl}]),
postid: postid,
postimage: photoUrl,
profile_image: profImage,
publisher: publisher,
like: [],
);
_firestore.collection('Posts').doc(postid).set(
post.toJson(),
);
res = "Successful";
print(post);
} catch (err) {
res = err.toString();
}
此行出錯
postImages: FieldValue.arrayUnion([{'0': newPhotoUrl}]),
錯誤代碼是:
The argument type 'FieldValue' can't be assigned to the parameter type 'String'.
uj5u.com熱心網友回復:
嘗試添加它
await _firestore.collection('Posts').doc(postid).update({
'postImages': FieldValue.arrayUnion([photoUrl]),
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/489332.html
上一篇:如何將字串資料轉換為偏移資料?
下一篇:一次訂閱父集合和子集合
