flutter_debounce_throttle 2.4.6
flutter_debounce_throttle: ^2.4.6 copied to clipboard
Prevent button spam, debounce search, and fix memory leaks in Flutter. Drop-in widgets, async loading states, auto-lifecycle management. Zero dependencies.
flutter_debounce_throttle #
The Traffic Control System for Flutter Apps #
Stop using manual
Timer. It causes memory leaks, crashes, and race conditions.
All-in-one package for debounce, throttle, rate limiting, and async concurrency control. Memory-safe, lifecycle-aware, and works with any state management solution.
| Debounced Search | Anti-Spam Button | Async Submit |
|---|---|---|
![]() |
![]() |
![]() |
| Concurrency Replace | Hooks Edition | Riverpod Integration |
![]() |
![]() |
![]() |
๐ Honest API โ No Silent Failures #
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.
// โ
compiler forces handling of both branches
final result = await throttler.call(() async => await submitOrder(orderId));
result.when(
onExecuted: () => showSuccessDialog(),
onDropped: () => showError('Server busy โ please try again.'),
);
30-Second 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)))
Async with loading state:
AsyncThrottledBuilder(
builder: (context, throttle, isLoading) => ElevatedButton(
onPressed: throttle(() async => await submitForm()),
child: Text(isLoading ? 'Submitting...' : 'Submit'),
),
)
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(); }
}
Widgets #
| Widget | Use Case |
|---|---|
ThrottledInkWell |
Button with ripple + throttle โ prevent double-tap |
DebouncedQueryBuilder |
Search input with loading state & auto-cancel |
AsyncThrottledBuilder |
Async button with loading lock |
ConcurrentAsyncThrottledBuilder |
4 concurrency modes (drop, replace, enqueue, keepLatest) |
ThrottledGestureDetector |
Drop-in GestureDetector replacement |
StreamDebounceListener |
Debounce stream events reactively |
Installation #
dependencies:
flutter_debounce_throttle: ^2.4.6
Quality Assurance #
| Guarantee | How |
|---|---|
| 570+ tests | Unit, integration, security, system, performance & stress tests |
| 98% coverage | All edge cases and branches verified |
| Honest API | ThrottlerResult / DebounceResult โ no silent failures |
| Memory-safe | Zero leaks verified with LeakTracker |
| Architecture-neutral | mixin not extends โ works with any framework |
GitHub ยท FAQ ยท API Reference ยท Best Practices
Made with craftsmanship by Brewkits





