like_button icon indicating copy to clipboard operation
like_button copied to clipboard

animation stopped

Open venky9885 opened this issue 3 years ago • 6 comments

When i used async function inside onbutton tapped ,animation is stopped,i tried many times or it will show initial color of button not updating liked color

venky9885 avatar May 24 '21 16:05 venky9885

My code


  Future<bool> onLikeButtonTapped(bool isLiked) async {
    ///bool val = isLiked;
    print((!isLiked).toString());
    if (!isLiked) {
      //val = !val;
      // _globalKey.currentState.onTap();
      mod.addLikes(data.id);
      print("liked");
    } else {
      //val = !val;
      //_globalKey.currentState.onTap();
      print("notliked");
    }

    /// send your request here
    // final bool success= await sendRequest();

    /// if failed, you can do nothing
    // return success? !isLiked:isLiked;

    return !isLiked;
  }
LikeButton(
                        onTap: onLikeButtonTapped,
                        // key: _globalKey,
                        // onTap: (isLiked) {
                        //   if (isLiked == null) {
                        //     isLiked = true;
                        //     mod.addLikes(data.id);
                        //   } else {
                        //     isLiked = true;
                        //     print("No");
                        //   }
                        //   //return isLiked;
                        // },
                        size: 40,
                        circleColor: CircleColor(
                            start: Color(0xff00ddff), end: Color(0xff0099cc)),
                        bubblesColor: BubblesColor(
                          dotPrimaryColor: Color(0xff33b5e5),
                          dotSecondaryColor: Color(0xff0099cc),
                        ),
                        likeBuilder: (bool isLiked) {
                          return Icon(
                            Icons.favorite,
                            color: isLiked
                                ? Colors.deepPurpleAccent
                                : Colors.black,
                            size: 40,
                          );
                        },
                        likeCount:
                            int.parse(data.data()['likeCount'].toString()),
                        countBuilder: (int count, bool isLiked, String text) {
                          var color =
                              isLiked ? Colors.deepPurpleAccent : Colors.grey;
                          Widget result;
                          if (count == 0) {
                            result = Text(
                              " 0 ",
                              style: TextStyle(
                                  color: color, fontWeight: FontWeight.w700),
                            );
                          } else
                            result = Text(
                              text.toString(),
                              style: TextStyle(
                                  color: color, fontWeight: FontWeight.w700),
                            );

                          return result;
                        },
                      ),````

venky9885 avatar May 24 '21 16:05 venky9885

please provide runnable demo

zmtzawqlp avatar May 25 '21 01:05 zmtzawqlp

https://user-images.githubusercontent.com/59081163/119432459-fe27cb00-bd31-11eb-958d-225097208e4e.mp4

Its again getting back to initial postion

venky9885 avatar May 25 '21 02:05 venky9885

In my case I solved it by updating a variable of the Widget. That way the likeBuilder rebuilds with that variable of the class and works. Otherwise the parameter is lost.

irian-codes avatar Jun 14 '21 21:06 irian-codes

Tell me how can I solve it

venky9885 avatar Jun 15 '21 02:06 venky9885

Tell me how can I solve it

You could be more respectful and try to solve the issue with the information I provided, before giving orders to anyone. Also, I have nothing to do with this project, I'm just an internet user.

irian-codes avatar Jun 16 '21 20:06 irian-codes

no more info for this issue, reopen if provide runnable demo

zmtzawqlp avatar Sep 29 '22 06:09 zmtzawqlp