HoldToConfirmButton

该软件包为Flutter应用提供了HoldToConfirmButton小部件。它允许用户按住按钮,当按下时,按钮会以视觉方式填充。填充完成后,将触发指定的操作。

安装

hold_to_confirm_button软件包添加为pubspec.yaml文件中的依赖项

dependencies:
  hold_to_confirm_button: ^latest_version # Replace with the latest version available on pub.dev

在你的Flutter项目中导入该软件包

import 'package:hold_to_confirm_button/hold_to_confirm_button.dart';

用法

默认值

HoldToConfirmButton(
  onProgressCompleted: () {
    // Handle the completed progress here
  },
  child: const Text('Hold to increase',
    style: TextStyle(color: Colors.white),
  ),
)

default button

自定义值

HoldToConfirmButton(
  onProgressCompleted: () {
    // Handle the completed progress here
  },
  child: const Text('Hold to increase'
    style: TextStyle(color: Colors.white),
  ),
  hapticFeedback: false,
  backgroundColor: Colors.green,
  borderRadius: BorderRadius.all(
    Radius.circular(12),
  ),
)

custom button

自定义

HoldToConfirmButton小部件提供了各种自定义选项,以匹配您应用的设计

  • child:显示在按钮区域内的窗口小部件(例如,文本、图标)。
  • hapticFeedback:启用或禁用按钮按下时的触觉反馈(默认为true)。
  • backgroundColor:设置按钮的背景颜色。
  • borderRadius:定义按钮的圆角。