如何求解错误[] IS不为类型定义的object'
静态void liketweet(字符串CurrentUserid,Tweet Tweet){ DocumentReference TweetDocProfile = tweetsref.doc(tweet.authorid).collection('usertweets')。doc(tweet.id); TweetDocProfile.get()。然后((doc){ int likes = doc.data()['likes']; //错误该运算符未针对类型的对象定义, TweetDocProfile.update({'likes':likes + 1}); });
DocumentReference tweetDocFeed =
feedRefs.doc(currentUserId).collection('userFeed').doc(tweet.id);
tweetDocFeed.get().then((doc) {
if (doc.exists) {
int likes = doc.data()['likes'];
tweetDocFeed.update({'likes': likes + 1});
}
});
likesRef.doc(tweet.id).collection('tweetLikes').doc(currentUserId).set({});
addActivity(currentUserId, tweet, false, null);
}
static void linketweet(字符串CurrentUserid,Tweet Tweet){ DocumentReference TweetDocProfile = tweetsref.doc(tweet.authorid).collection('usertweets')。doc(tweet.id); TweetDocProfile.get()。然后((doc){ int likes = doc.data()['likes']; TweetDocProfile.update({'likes':likes -1}); });
DocumentReference tweetDocFeed =
feedRefs.doc(currentUserId).collection('userFeed').doc(tweet.id);
tweetDocFeed.get().then((doc) {
if (doc.exists) {
int likes = doc.data()['likes'];
tweetDocFeed.update({'likes': likes - 1});
}
});
likesRef
.doc(tweet.id)
.collection('tweetLikes')
.doc(currentUserId)
.get()
.then((doc) => doc.reference.delete());
}
static void likeTweet(String currentUserId, Tweet tweet) {
DocumentReference tweetDocProfile =
tweetsRef.doc(tweet.authorId).collection('userTweets').doc(tweet.id);
tweetDocProfile.get().then((doc) {
int likes = doc.data()['likes']; //error the operator isn't defined for the type 'object,
tweetDocProfile.update({'likes': likes + 1});
});
DocumentReference tweetDocFeed =
feedRefs.doc(currentUserId).collection('userFeed').doc(tweet.id);
tweetDocFeed.get().then((doc) {
if (doc.exists) {
int likes = doc.data()['likes'];
tweetDocFeed.update({'likes': likes + 1});
}
});
likesRef.doc(tweet.id).collection('tweetLikes').doc(currentUserId).set({});
addActivity(currentUserId, tweet, false, null);
}
static void unlikeTweet(String currentUserId, Tweet tweet) {
DocumentReference tweetDocProfile =
tweetsRef.doc(tweet.authorId).collection('userTweets').doc(tweet.id);
tweetDocProfile.get().then((doc) {
int likes = doc.data()['likes'];
tweetDocProfile.update({'likes': likes - 1});
});
DocumentReference tweetDocFeed =
feedRefs.doc(currentUserId).collection('userFeed').doc(tweet.id);
tweetDocFeed.get().then((doc) {
if (doc.exists) {
int likes = doc.data()['likes'];
tweetDocFeed.update({'likes': likes - 1});
}
});
likesRef
.doc(tweet.id)
.collection('tweetLikes')
.doc(currentUserId)
.get()
.then((doc) => doc.reference.delete());
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用此而不是只需要一个键:
如果您想要整个对象,则需要将其施放为Map< string,dynamic>
Use this instead of you want only one key:
If you want the entire object, you need to cast it as Map<String, dynamic>