{"id":13551235,"url":"https://github.com/fluttercandies/like_button","last_synced_at":"2025-05-16T18:08:47.428Z","repository":{"id":34910464,"uuid":"188774366","full_name":"fluttercandies/like_button","owner":"fluttercandies","description":"Like Button is a flutter library that allows you to create a button with animation effects similar to Twitter's heart when you like something and animation effects to increase like count.","archived":false,"fork":false,"pushed_at":"2024-06-24T10:10:56.000Z","size":3372,"stargazers_count":471,"open_issues_count":8,"forks_count":97,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-03T17:12:57.471Z","etag":null,"topics":["flutter-library","like-animation","like-button","twitter-heart"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fluttercandies.png","metadata":{"files":{"readme":"README-ZH.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":"http://zmtzawqlp.gitee.io/my_images/images/qrcode.png"}},"created_at":"2019-05-27T05:07:42.000Z","updated_at":"2025-02-15T09:08:17.000Z","dependencies_parsed_at":"2024-01-16T18:59:39.071Z","dependency_job_id":"831732b3-6e72-4906-80f5-dabe4dc1d141","html_url":"https://github.com/fluttercandies/like_button","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercandies%2Flike_button","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercandies%2Flike_button/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercandies%2Flike_button/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercandies%2Flike_button/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fluttercandies","download_url":"https://codeload.github.com/fluttercandies/like_button/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248599296,"owners_count":21131257,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flutter-library","like-animation","like-button","twitter-heart"],"created_at":"2024-08-01T12:01:44.572Z","updated_at":"2025-05-16T18:08:47.412Z","avatar_url":"https://github.com/fluttercandies.png","language":"Dart","funding_links":["http://zmtzawqlp.gitee.io/my_images/images/qrcode.png"],"categories":["Dart"],"sub_categories":[],"readme":"# like_button\n\n[![pub package](https://img.shields.io/pub/v/like_button.svg)](https://pub.dartlang.org/packages/like_button) [![GitHub stars](https://img.shields.io/github/stars/fluttercandies/like_button)](https://github.com/fluttercandies/like_button/stargazers) [![GitHub forks](https://img.shields.io/github/forks/fluttercandies/like_button)](https://github.com/fluttercandies/like_button/network)  [![GitHub license](https://img.shields.io/github/license/fluttercandies/like_button)](https://github.com/fluttercandies/like_button/blob/master/LICENSE)  [![GitHub issues](https://img.shields.io/github/issues/fluttercandies/like_button)](https://github.com/fluttercandies/like_button/issues) \u003ca href=\"https://qm.qq.com/q/ZyJbSVjfSU\"\u003e![FlutterCandies QQ 群](https://img.shields.io/badge/dynamic/yaml?url=https%3A%2F%2Fraw.githubusercontent.com%2Ffluttercandies%2F.github%2Frefs%2Fheads%2Fmain%2Fdata.yml\u0026query=%24.qq_group_number\u0026label=QQ%E7%BE%A4\u0026logo=qq\u0026color=1DACE8)\n\n文档语言: [English](README.md) | [中文简体](README-ZH.md)\n\nLike Button 支持推特点赞效果和喜欢数量动画的Flutter库.\n\n感谢 [jd-alexander](https://github.com/jd-alexander/LikeButton) and [吉原拉面](https://github.com/yumi0629/FlutterUI/tree/master/lib/likebutton) 对点赞动画的原理的开源。\n\n[Flutter 仿掘金推特点赞按钮](https://juejin.im/post/5cee3b43e51d45773f2e8ed7)  \n\n[Web Demo for LikeButton](https://fluttercandies.github.io/like_button/)\n\n![](https://github.com/fluttercandies/Flutter_Candies/blob/master/gif/like_button/like_button.gif)\n\n- [like_button](#likebutton)\n  - [如何使用.](#%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8)\n  - [什么时候去请求服务改变状态](#%e4%bb%80%e4%b9%88%e6%97%b6%e5%80%99%e5%8e%bb%e8%af%b7%e6%b1%82%e6%9c%8d%e5%8a%a1%e6%94%b9%e5%8f%98%e7%8a%b6%e6%80%81)\n  - [参数](#%e5%8f%82%e6%95%b0)\n\n##  如何使用.\n\n默认效果是Icons.favorite\n```dart\n  LikeButton(),\n```\n\n你可以自定义一些效果，比如颜色，比如喜欢数量显示，\n```dart\n  LikeButton(\n          size: buttonSize,\n          circleColor:\n              CircleColor(start: Color(0xff00ddff), end: Color(0xff0099cc)),\n          bubblesColor: BubblesColor(\n            dotPrimaryColor: Color(0xff33b5e5),\n            dotSecondaryColor: Color(0xff0099cc),\n          ),\n          likeBuilder: (bool isLiked) {\n            return Icon(\n              Icons.home,\n              color: isLiked ? Colors.deepPurpleAccent : Colors.grey,\n              size: buttonSize,\n            );\n          },\n          likeCount: 665,\n          countBuilder: (int count, bool isLiked, String text) {\n            var color = isLiked ? Colors.deepPurpleAccent : Colors.grey;\n            Widget result;\n            if (count == 0) {\n              result = Text(\n                \"love\",\n                style: TextStyle(color: color),\n              );\n            } else\n              result = Text(\n                text,\n                style: TextStyle(color: color),\n              );\n            return result;\n          },\n        ),\n```\n\n## 什么时候去请求服务改变状态\n```dart\n    LikeButton(\n      onTap: onLikeButtonTapped,\n    ),\n```\n这是一个异步回调，你可以等待服务返回之后再改变状态。也可以先改变状态，请求失败之后重置回状态\n\n```dart\n  Future\u003cbool\u003e onLikeButtonTapped(bool isLiked) async{\n    /// send your request here\n    // final bool success= await sendRequest();\n\n    /// if failed, you can do nothing\n    // return success? !isLiked:isLiked;\n\n    return !isLiked;\n  }\n```\n\n## 参数\n| 参数                       | 描述                                                                                                  | 默认                                                                                                                                                                                  |\n| -------------------------- | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| size                       | like Widget的大小                                                                                     | 30.0                                                                                                                                                                                  |\n| animationDuration          | like widget动画的时间                                                                                 | const Duration(milliseconds: 1000)                                                                                                                                                    |\n| bubblesSize                | 动画时候的泡泡的大小                                                                                  | size * 2.0                                                                                                                                                                            |\n| bubblesColor               | 动画时候的泡泡的颜色，需要设置4种                                                                     | const BubblesColor(dotPrimaryColor: const Color(0xFFFFC107),dotSecondaryColor: const Color(0xFFFF9800),dotThirdColor: const Color(0xFFFF5722),dotLastColor: const Color(0xFFF44336),) |\n| circleSize                 | 动画时候的圈的最大大小                                                                                | size * 0.8                                                                                                                                                                            |\n| circleColor                | 动画时候的圈的颜色，需要设置2种                                                                       | const CircleColor(start: const Color(0xFFFF5722), end: const Color(0xFFFFC107)                                                                                                        |\n| onTap                      | 点击时候的回调，你可以在里面请求服务改变状态                                                          |                                                                                                                                                                                       |\n| isLiked                    | 是否喜欢。如果设置null的话，将会一直有动画，而且喜欢数量一直增长                                      | false                                                                                                                                                                                 |\n| likeCount                  | 喜欢数量。如果为null的话，不显示                                                                      | null                                                                                                                                                                                  |\n| mainAxisAlignment          | MainAxisAlignment ，like widget和like count widget是放在一个Row里面的，对应Row的mainAxisAlignment属性 | MainAxisAlignment.center                                                                                                                                                              |\n| likeBuilder                | like widget的创建回调                                                                                 | null                                                                                                                                                                                  |\n| countBuilder               | like count widget的创建回调                                                                           | null                                                                                                                                                                                  |\n| likeCountAnimationDuration | 喜欢数量变化动画的时间                                                                                | const Duration(milliseconds: 500)                                                                                                                                                     |\n| likeCountAnimationType     | 喜欢数量动画的类型(none,part,all)。没有动画；只动画改变的部分；全部部分                               | LikeCountAnimationType.part                                                                                                                                                           |\n| likeCountPadding           | like count widget 跟 like widget的间隔                                                                | const EdgeInsets.only(left: 3.0)                                                                                                                                                      |\n| countPostion               | top,right,bottom,left. count的位置(上下左右)                                                          | CountPostion.right                                                                                                                                                                    |\n| countDecoration            | count 的修饰器，你可以通过它为count增加其他文字或者效果                                               | null                                                                                                                                                                                  |  |\n| postFrameCallback          | 第一帧回调返回 LikeButtonState                                                                        | null                                                                                                                                                                                  |\n\n## ☕️Buy me a coffee\n\n![img](http://zmtzawqlp.gitee.io/my_images/images/qrcode.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluttercandies%2Flike_button","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffluttercandies%2Flike_button","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluttercandies%2Flike_button/lists"}