参数类型'Null Function(Reaction, int)'不能分配给参数类型"动态函数(反应,整数,布尔值)"



你好,我在我的代码中有以下错误。我真的非常感谢任何帮助!这是错误输出

错误:参数类型'Null Function(Reaction, int)'不能分配给参数类型'dynamic Function(Reaction, int, bool)'.

  • 'Reaction'来自'package:flutter_reaction button/src/Reaction'。飞镖 ' ('../../../颤振/.pub-cache/托管/pub.dartlang.org/flutter_reaction_button-1.0.7 + 3/lib/src/reaction.dart")。onReactionChanged:(反应,isChecked) {和

错误:int类型的值不能赋值给bool类型的变量。if (isChecked) {^

^


return FlutterReactionButtonCheck(
onReactionChanged: (reaction, isChecked) {
setState(() {
post.myReaction = Reaction(
id: reaction.id,
icon: reaction.icon,
previewIcon: reaction.previewIcon);
});
if (isChecked) {
bool isNewReaction = false;
SocialReactionModel postReaction =
_reactionsList.firstWhere(
(element) =>
element.postID == post.id,
orElse: () {
isNewReaction = true;
String reactionString =
getReactionString(reaction.id);
SocialReactionModel newReaction =
SocialReactionModel(
postID: post.id,
createdAt: Timestamp.now(),
reactionAuthorID:
MyAppState.currentUser.userID,
reaction: reactionString);
_reactionsList.add(newReaction);
return newReaction;
});
if (isNewReaction) {
setState(() {
post.reactionsCount++;
});
fireStoreUtils.postReaction(
postReaction, post);
} else {
postReaction.reaction =
getReactionString(reaction.id);
postReaction.createdAt = Timestamp.now();
fireStoreUtils.updateReaction(
postReaction, post);
}
} else {
_reactionsList.removeWhere(
(element) => element.postID == post.id);
setState(() {
post.reactionsCount--;
});
fireStoreUtils.removeReaction(post);
}
},

我认为是旧版本,尽量使用最新版本:

flutter_reaction_button: ^2.0.0

相关内容

  • 没有找到相关文章

最新更新