flutter_debounce_throttle

High-performance, memory-safe, and lifecycle-aware traffic control for Flutter & Dart. Debounce, throttle, rate limiting (Token Bucket), and async concurrency control with Zero Silent Failures.
| Debounced Search |
Anti-Spam Button |
Async Submit |
 |
 |
 |
| Concurrency Replace |
Hooks Edition |
Riverpod Integration |
 |
 |
 |
🚀 What’s New in v2.4.6: The Honest API
Most libraries return void, causing “silent failures” where dropped operations appear to succeed. This library introduces ThrottlerResult and DebounceResult to ensure your code handles every outcome.
// ✅ Honest API — both branches required at compile time
final result = await throttler.call(() async => await processPayment(order));
result.when(
onExecuted: () => showSuccessDialog(), // Safe: payment actually ran
onDropped: () => showError('Busy!'), // Handled: user knows it failed
);
Quick Start
Anti-spam button — 1 line:
ThrottledInkWell(onTap: () => processPayment(), child: Text('Pay \$99'))
Debounced search:
final debouncer = Debouncer(duration: 300.ms);
TextField(onChanged: (s) => debouncer(() => search(s)))
State management (Provider, Riverpod, GetX, Bloc):
class SearchController with ChangeNotifier, EventLimiterMixin {
void onSearch(String text) {
debounce('search', () async {
_results = await api.search(text);
notifyListeners();
});
}
@override
void dispose() { cancelAll(); super.dispose(); }
}
Which Package?
Why This Library?
| Capability |
This Library |
easy_debounce |
Manual Timer |
| Honest API (No Silent Failures) |
✅ |
❌ |
❌ |
| Memory Safe (Auto-dispose) |
✅ |
❌ |
❌ Leaky |
| Async & Future Support |
✅ |
❌ |
❌ |
| Race Condition Control (4 modes) |
✅ |
❌ |
❌ |
| Ready-to-use Widgets |
✅ |
❌ |
❌ |
| Distributed Rate Limiting |
✅ |
❌ |
❌ |
| Zero External Dependencies |
0 |
0 |
0 |
Quality & Reliability
|
|
| 570+ tests |
Unit, widget, integration, security, performance & stress tests |
| 98% coverage |
Every branch and edge case verified |
| Security First |
DoS protection and memory exhaustion guards built-in |
| Type-safe |
Full generics, no dynamic, compile-time safety with when() |
| Memory-safe |
Verified with Flutter LeakTracker to ensure zero leaks |
Documentation
Made with craftsmanship by Brewkits
评论