GeekAbdelouahed / flutter-reaction-button

Flutter Reaction Button is a customizable Flutter package that allows you to easily create interactive buttons with reaction emojis, similar to Facebook's iconic reaction buttons.
https://pub.dev/packages/flutter_reaction_button
MIT License
215 stars 78 forks source link

InitialReaction not updating as Expected/ #10

Closed sivaram16 closed 4 years ago

sivaram16 commented 4 years ago

Hey guys, first of all thanks for this plugin and i am facing the issue while implementing it in one of my project, could you guys help me out of this. Thanks in advance.

Version : flutter_reaction_button: ^1.0.2

Here is my code:

                    FlutterReactionButtonCheck(
                         onReactionChanged: (reaction, isChecked) {
                         this.widget.post.isLike = !this.widget.post.isLike;
                        setState(() {});
                         print('reaction selected id: ${reaction.id}');
                           print('isChecked $isChecked');
                          },
                       reactions: Reactions.reactions,
                        initialReaction: this.widget.post.isLike
                          ? Reactions.reactions[0]
                        : Reactions.defaultInitialReaction,
                       selectedReaction: Reactions.reactions[0],
                        boxRadius: 26,
                        ),
                       ),

if you see the above code i am changing the initial reaction dynamically according to my needs whenever its change its not updating its always renders the first what we give to it. I saw the code of the implementation there its setted in initstate does that is prob or any other? @GeekAbdelouahed @mostafaAbdelazim

mostafaAbdelazim commented 4 years ago

Try setting isChecked constructor param to true and the initial reaction will be displayed by default @ThalapathySiva

SchnMar commented 4 years ago

Hey, also thank you for this plugin. I'm facing the same issue. I'm saving the reaction to a database and on reload I want the relevant reaction to be displayed as selected reaction. Unfortunately, the isChecked constructor is not available or I can't see it.

@mostafaAbdelazim Can you please provide an example? Couldn't find it in the package examples...

Thank you

mostafaAbdelazim commented 4 years ago

@SchnMar It has been recently added in this PR https://github.com/GeekAbdelouahed/flutter-reaction-button/pull/8 Maybe it's not updated on pub yet

sivaram16 commented 4 years ago

@mostafaAbdelazim I have checked that can you try my code and see the result what i am facing? The things is if we change any of the reactions from the box its changing correctly if i not pressing longpress just pressed clicked its not changing to unlike thats the issue i am facing and mostly the initialReaction not rebuilding so its showings always the same when we passed at first. thanks for your reply.

GeekAbdelouahed commented 4 years ago

Hi @ThalapathySiva thanks for your support. I made few changes in the new version try it please

sivaram16 commented 4 years ago

@GeekAbdelouahed thanks for your support the problem was on my side you can close this .