Flutter Duration Button
Duration Button 是一款类似于 Netflix 的“跳过片头”按钮,可以自动点击。
它提供了名为 DurationButton 的普通持续时间按钮,名为 IconDurationButton 的基于图标的按钮,名为 TextDurationButton 的基于文本的按钮,以及名为 TextDurationButton 的带边框按钮。
入门
依赖它。
$ flutter pub add duration_button
或者
将以下行添加到您的个人软件包的 pubspec.yaml 中。
dependencies:
duration_button: ^1.0.0
然后运行 flutter pub get 进行安装。
导入它。
import 'package:duration_button/duration_button.dart';
使用小部件。
DurationButton(/* Props here.. */)
IconDurationButton(/* Props here.. */)
OutlinedDurationButton(/* Props here.. */)
TextDurationButton(/* Props here.. */)
Props
| Props | 类型 | 默认值 | 描述 |
|---|---|---|---|
| duration | 持续时间 |
必需 | 按钮的 Duration 值。 |
| width | double? |
空 |
按钮的宽度值。 |
| 高度 | double? |
空 |
按钮的高度值。 |
| child | Widget? |
空 |
按钮的子小部件。 |
| coverChild | bool? |
假 |
如果 cover 覆盖了子小部件,则为布尔值。 |
| borderRadius | BorderRadius |
空 |
按钮的边框半径。 |
| onPressed | VoidCallback |
必需 | 按钮被点击时将调用的回调函数。如果 onComplete 为 null,则在完成时将调用 onPressed。 |
| onComplete | VoidCallback? |
空 |
按钮完全覆盖时将调用的回调函数。 |
| coverColor | Color? |
Colors.black.withOpacity(0.2) |
按钮的颜色值。 |
| backgroundColor | Color? |
主题主色 | 按钮的颜色值。 |
| hoverColor | Color? |
空 |
悬停效果的颜色值。 |
| splashColor | Color? |
空 |
飞溅效果的颜色值。 |
| splashFactory | InteractiveInkFeatureFactory? |
空 |
按钮的 splashFactory 值。 |
| border | Border? |
空 |
按钮的边框值。 |
您可以在 文档 中找到其他小部件的 Props。
示例
DurationButton
DurationButton(
duration: const Duration(seconds: 3),
onPressed: () {},
backgroundColor: Colors.yellow,
splashFactory: NoSplash.splashFactory,
onComplete: () => ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("onCompleteCalled!"))),
child: const Text("Duration Button"),
),
IconDurationButton
IconDurationButton(
Icons.favorite,
size: 30,
iconColor: Colors.pink,
onPressed: () {},
duration: const Duration(seconds: 2),
),
TextDurationButton
TextDurationButton(
width: 150,
height: 50
duration: const Duration(seconds: 7),
text: const Text('Text Duraion Button'),
onPressed: () {},
),
OutlinedDurationButton
// String _skipIntro = 'Skip Intro';
OutlinedDurationButton(
child: Text(_skipIntro),
onPressed: () {},
onComplete: () => setState(() => _skipIntro = 'Intro Skipped'),
duration: const Duration(seconds: 3),
),
许可证
MIT License
Copyright (c) 2022 Kim Seung Hwan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
