taplatch 0.1.0
taplatch: ^0.1.0 copied to clipboard
A Flutter async button that prevents repeated taps, shows loading, handles errors, and supports a success cooldown.
TapLatch #
A small Flutter button that prevents repeated taps while an async callback is running. Supports a spinner, success cooldown, custom style, and error handling.
This is starter source code. Package name availability and publishing status have not been verified.
Try the example #
cd example
flutter create . --platforms=web
flutter pub get
flutter run -d chrome
For the core package tests:
flutter pub get
flutter analyze
flutter test
flutter pub publish --dry-run
Use locally in another Flutter application #
In your app's pubspec.yaml:
dependencies:
taplatch:
path: ../taplatch
Then:
import 'package:taplatch/taplatch.dart';
TapLatchButton(
label: 'Book Now',
loadingLabel: 'Booking...',
cooldown: const Duration(seconds: 2),
onPressed: () async {
await bookingService.createBooking();
},
onSuccess: () {
// Show success feedback.
},
onError: (error, stackTrace) {
// Show failure feedback.
},
)
bookingService in the snippet represents your own application's service, not a bundled API.
Options #
| Property | Type | Purpose |
|---|---|---|
label |
String |
Button text |
onPressed |
Future<void> Function() |
Protected async operation |
loadingLabel |
String? |
Text during loading |
icon |
Widget? |
Idle icon |
loader |
Widget? |
Custom loading widget |
style |
ButtonStyle? |
ElevatedButton style |
enabled |
bool |
External enabled flag |
cooldown |
Duration |
Delay further taps after success |
onSuccess |
VoidCallback? |
Completion callback |
onError |
void Function(Object, StackTrace)? |
Error callback |
Important: TapLatch only prevents duplicate taps in this widget instance. For real bookings, orders, and payments, enforce idempotency and reconciliation on the server as well. Do not put private API credentials in a package published to pub.dev.
Publishing #
- Confirm package name availability on https://pub.dev.
- Add your real repository/homepage links to
pubspec.yamlif available. - Ensure
LICENSE,README.md, andCHANGELOG.mdare correct. - Run
flutter analyze,flutter test,flutter pub publish --dry-run. - If checks pass, run
flutter pub publish.