Flutter 闪动按钮效果

1,440 阅读1分钟

Flutter 闪动按钮效果pub仓库地址

Flutter 闪动按钮效果github仓库地址

效果如下:

Twinkle Button

下载安装:

在 pubspec.yaml 中添加依赖

dependencies:
  ...
  twinkle_button: ^0.0.1

在命令行中执行这句话

flutter packages get

使用方法:

import 'package:twinkle_button/twinkle_button.dart';
TwinkleButton(
  buttonTitle: Text(
    'Subscribe with Free Trial',
    style: TextStyle(
      color: Colors.white,
          fontWeight: FontWeight.w300,
          fontSize: 17.0,
        ),
    ),
    buttonColor: Color(0xff3dce89),
    onclickButtonFunction: () {
      print('hello');
    }
);

参数

Parameter Default Description
buttonTitle null 按钮的文字,不能为空。
buttonColor null 按钮的颜色,不能为空。
buttonHeight 50.0 按钮的高度。
buttonWidth 200.0 按钮的宽度。
durationTime 3 闪烁间隔时间。(单位:秒)
twinkleTime 300 闪烁时间。(单位:毫秒)
highlightColor Colors.white 闪烁背景颜色。
onclickButtonFunction null 点击按钮触发的事件,不能为空。