flutter_smart_debouncer 1.0.0
flutter_smart_debouncer: ^1.0.0 copied to clipboard
A unified package providing debouncing utilities and smart Flutter widgets (TextField, Button, etc.).
flutter_smart_debouncer #
flutter_smart_debouncer is a unified toolkit for taming noisy inputs. It
combines production-ready debouncing utilities with polished Flutter widgets so
you can guard API calls, smooth out text entry, and prevent accidental double
submits using a single dependency.
Debouncing coalesces a burst of events into a single callback once the user pauses. It keeps search boxes snappy, throttles autosave traffic, and prevents repeated taps on important buttons.
Quick start #
Add the package to your app:
dependencies:
flutter_smart_debouncer: ^1.0.0
Debounce anything in Dart code #
final searchDebouncer = Debouncer<void>(
delay: const Duration(milliseconds: 300),
);
Future<void> onQueryChanged(String value) {
return searchDebouncer(() async {
await searchApi(value);
});
}
SmartDebouncerTextField #
SmartDebouncerTextField(
delay: const Duration(milliseconds: 250),
decoration: const InputDecoration(labelText: 'Search'),
onChangedDebounced: (value) {
debugPrint('Searching for $value');
},
);
SmartDebouncerButton #
SmartDebouncerButton(
delay: const Duration(milliseconds: 600),
child: const Text('Submit'),
onPressed: () {
debugPrint('Submitted once');
},
);
What's inside? #
- ✅ Battle-tested debouncer with leading/trailing edges,
maxWait, cancel, and flush APIs - ✅ Widget wrappers for text fields and buttons built on top of the same debouncer
- ✅ Stream helpers, throttle utilities, and reactive
DebouncedValue - ✅ Thorough tests, lints, and an example Flutter app demonstrating both styles
Example app #
See example/lib/main.dart for a Flutter demo that
simulates an API call using the core Debouncer and shows the smart widgets in
a material UI.
Run it with:
flutter run
Changelog #
See CHANGELOG.md for release notes.
License #
Distributed under the MIT License.