📅  最后修改于: 2023-12-03 15:28:56.621000             🧑  作者: Mango
这是一个用Dart编写的控件,它可以在按钮上绘制一个颤动的轮廓,以增加用户的交互反馈。
在pubspec.yaml中添加以下依赖:
dependencies:
shaking_button_outline: ^1.0.0
导入以下包:
import 'package:shaking_button_outline/shaking_button_outline.dart';
创建ShakingButtonOutline控件,设置其参数并添加到UI中。
ShakingButtonOutline(
child: FlatButton(
onPressed: () {},
child: Text('按钮'),
),
interval: 100,
strokeWidth: 6,
strokeColor: Colors.red,
)
| 参数 | 类型 | 默认值 | 描述 | | ---- | ---- | ---- | ---- | | child | Widget | null | 待添加效果的子控件 | | interval | int | 120 | 动画周期,即颤动一周所需时间(单位:毫秒)| | strokeWidth | double | 3.0 | 轮廓线宽度 | | strokeColor | Color | Colors.grey[300] | 轮廓线颜色 | | offset | double | 10.0 | 颤动幅度 |
可以查看该仓库的 example 代码以了解更多示例。