https://github.com/outdatedguy/hold_down_button
A Flutter package to trigger an action repeatedly when a widget is hold/pressed down.
https://github.com/outdatedguy/hold_down_button
flutter-package
Last synced: 11 months ago
JSON representation
A Flutter package to trigger an action repeatedly when a widget is hold/pressed down.
- Host: GitHub
- URL: https://github.com/outdatedguy/hold_down_button
- Owner: OutdatedGuy
- License: bsd-3-clause
- Created: 2022-05-19T15:58:16.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-01T16:57:45.000Z (over 1 year ago)
- Last Synced: 2025-02-17T13:38:08.450Z (12 months ago)
- Topics: flutter-package
- Language: C++
- Homepage: https://pub.dev/packages/hold_down_button
- Size: 705 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Hold Down Button
A Flutter package to trigger an action repeatedly when a widget is hold/pressed down.
[![pub package][package_svg]][package]
[![GitHub][license_svg]](LICENSE)
[![GitHub issues][issues_svg]][issues]
[![GitHub issues closed][issues_closed_svg]][issues_closed]
## Features
- `HoldDownButton` displays the child widget passed to it and acts when it is pressed.
- You can customize the **_time delay curve_** to make the button trigger action more or less quickly.
- Also you can set time delay for the periodic function call.

## Getting started
#### Add to Dependencies
```yaml
hold_down_button: ^1.1.0
```
#### Import the package
```dart
import 'package:hold_down_button/hold_down_button.dart';
```
## Usage
#### Using the Widget with default values
```dart
HoldDownButton(
onHoldDown: () => print('Pressed'),
child: ElevatedButton(
onPressed: () => print('Pressed'),
child: const Text('ElevatedButton'),
),
),
```
#### Customizing initial delay curve
```dart
HoldDownButton(
onHoldDown: () => print('Pressed'),
longWait: const Duration(seconds: 1),
middleWait: const Duration(milliseconds: 750),
minWait: const Duration(milliseconds: 500),
child: ElevatedButton(
onPressed: () => print('Pressed'),
child: const Text('ElevatedButton'),
),
),
```
#### Changing the time delay for periodic function call
```dart
HoldDownButton(
onHoldDown: () => print('Pressed'),
holdWait: const Duration(milliseconds: 200),
child: ElevatedButton(
onPressed: () => print('Pressed'),
child: const Text('ElevatedButton'),
),
),
```
## Description
| Field | Description | Type | Default |
| :----------: | :-------------------------------------------------------: | :------------: | :---------------------------------: |
| `child` | **The child widget to be displayed.** | _Widget_ | - |
| `onHoldDown` | **The callback to be called when the button is pressed.** | _VoidCallback_ | - |
| `holdWait` | **The time delay for periodic function call.** | _Duration_ | `const Duration(milliseconds: 100)` |
| `longWait` | **Time delay 2nd function call.** | _Duration_ | `const Duration(milliseconds: 500)` |
| `middleWait` | **Time delay 3rd function call.** | _Duration_ | `const Duration(milliseconds: 350)` |
| `minWait` | **Time delay 4th function call.** | _Duration_ | `const Duration(milliseconds: 200)` |
### If you liked the package, then please give it a [Like 👍🏼][package] and [Star ⭐][repository]
[package_svg]: https://img.shields.io/pub/v/hold_down_button.svg?color=blueviolet
[license_svg]: https://img.shields.io/github/license/OutdatedGuy/hold_down_button.svg?color=purple
[issues_svg]: https://img.shields.io/github/issues/OutdatedGuy/hold_down_button.svg
[issues_closed_svg]: https://img.shields.io/github/issues-closed/OutdatedGuy/hold_down_button.svg?color=green
[package]: https://pub.dev/packages/hold_down_button
[repository]: https://github.com/OutdatedGuy/hold_down_button
[issues]: https://github.com/OutdatedGuy/hold_down_button/issues
[issues_closed]: https://github.com/OutdatedGuy/hold_down_button/issues?q=is%3Aissue+is%3Aclosed