搜索插件、代码仓与 APP 分类

like_button 封面
插件详情v2.1.0

like_button

Like Button 是一个 Flutter 库,允许你创建一个类似于 Twitter 点赞时心形动画效果的按钮。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
3.2万
喜欢数
1420
Pub 分数
150

安装插件

flutter pub add like_button

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

LikeButton 是一个 Flutter 包,提供一种带有动画效果的点赞按钮,其效果让人联想到 Twitter 的心形动画。它使用户能够通过点赞与内容进行互动,具有流畅的动画和可自定义的样式。该包支持 Android、iOS、Web、macOS、Windows 和 Linux 等多个平台,非常适合用于跨平台社交媒体应用。它可通过 pub.dev 轻松集成,并提供选项来自定义图标、颜色、大小和动画行为。

适合场景

  • 社交媒体应用互动
  • 内容点赞功能
  • 用户参与度跟踪
  • 交互式 UI 元素
  • 实时反馈机制

主要特点

  • 动画心形效果
  • 可自定义图标和颜色
  • 跨平台兼容性
  • 与 pub.dev 的轻松集成
  • 支持轻触和长按手势

适合对象

  • 开发社交应用的开发者
  • 寻求吸引人的按钮的UI设计师
  • 需要用户交互反馈的项目
  • 具有内容共享或评分系统的应用
  • Flutter 初学者探索动画

使用建议

  • 可能需要额外的状态管理
  • 低端设备上的动画性能
  • 超出基本样式的定制功能有限
  • 依赖外部依赖项以实现完整功能
  • 不适用于高频使用场景

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

like_button

pub package GitHub stars GitHub forks GitHub license GitHub issues FlutterCandies QQ 群

Language: English | 中文简体

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.

Reference codes from jd-alexander and 吉原拉面 ,thank them for open source code.

Web Demo for LikeButton

How to use it.

the default effects is Icons.favorite

  LikeButton(),

and you can also define custom effects.

  LikeButton(
          size: buttonSize,
          circleColor:
              CircleColor(start: Color(0xff00ddff), end: Color(0xff0099cc)),
          bubblesColor: BubblesColor(
            dotPrimaryColor: Color(0xff33b5e5),
            dotSecondaryColor: Color(0xff0099cc),
          ),
          likeBuilder: (bool isLiked) {
            return Icon(
              Icons.home,
              color: isLiked ? Colors.deepPurpleAccent : Colors.grey,
              size: buttonSize,
            );
          },
          likeCount: 665,
          countBuilder: (int count, bool isLiked, String text) {
            var color = isLiked ? Colors.deepPurpleAccent : Colors.grey;
            Widget result;
            if (count == 0) {
              result = Text(
                "love",
                style: TextStyle(color: color),
              );
            } else
              result = Text(
                text,
                style: TextStyle(color: color),
              );
            return result;
          },
        ),

The time to send your request

    LikeButton(
      onTap: onLikeButtonTapped,
    ),
  Future<bool> onLikeButtonTapped(bool isLiked) async{
    /// send your request here
    // final bool success= await sendRequest();

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

    return !isLiked;
  }

parameters

parameter description default
size size of like widget 30.0
animationDuration animation duration to change isLiked state const Duration(milliseconds: 1000)
bubblesSize total size of bubbles size * 2.0
bubblesColor colors of bubbles const BubblesColor(dotPrimaryColor: const Color(0xFFFFC107),dotSecondaryColor: const Color(0xFFFF9800),dotThirdColor: const Color(0xFFFF5722),dotLastColor: const Color(0xFFF44336),)
circleSize final size of circle size * 0.8
circleColor colors of circle const CircleColor(start: const Color(0xFFFF5722), end: const Color(0xFFFFC107)
onTap tap call back of like button,you can handle your request in this call back
isLiked whether it is liked(if it's null, always show like animation and increase like count) false
likeCount if null, will not show) null
mainAxisAlignment MainAxisAlignment for like button MainAxisAlignment.center
likeBuilder builder to create like widget null
countBuilder builder to create like count widget null
likeCountAnimationDuration animation duration to change like count const Duration(milliseconds: 500)
likeCountAnimationType animation type to change like count(none,part,all) LikeCountAnimationType.part
likeCountPadding padding for like count widget const EdgeInsets.only(left: 3.0)
countPostion top,right,bottom,left of like button widget CountPostion.right
countDecoration decoration of like count widget null
postFrameCallback call back of first frame with LikeButtonState null

所属分类

源码仓库

使用此插件的项目