flutter_debounce_throttle_core 1.0.0 copy "flutter_debounce_throttle_core: ^1.0.0" to clipboard
flutter_debounce_throttle_core: ^1.0.0 copied to clipboard

Pure Dart core for flutter_debounce_throttle. Zero external dependencies. Debounce, throttle, and rate limit with no Flutter dependency. Works on Mobile, Web, Desktop, Server, and CLI.

flutter_debounce_throttle_core #

Pure Dart core library for debounce and throttle operations. Zero Flutter dependencies - works on Mobile, Web, Desktop, Server, and CLI.

Installation #

dependencies:
  flutter_debounce_throttle_core: ^1.0.0

Quick Start #

Basic Throttle (prevent spam clicks) #

final throttler = Throttler(duration: Duration(milliseconds: 500));
throttler.call(() => submitForm());
// Don't forget to dispose!
throttler.dispose();

Basic Debounce (wait for user to stop) #

final debouncer = Debouncer(duration: Duration(milliseconds: 300));
debouncer.call(() => search(query));
debouncer.dispose();

Async Throttle (API calls) #

final asyncThrottler = AsyncThrottler(maxDuration: Duration(seconds: 15));
await asyncThrottler.call(() async => await api.submit());
asyncThrottler.dispose();

Async Debounce (search autocomplete) #

final asyncDebouncer = AsyncDebouncer(duration: Duration(milliseconds: 300));
final result = await asyncDebouncer.run(() async => await searchApi(query));
if (result == null) return; // Cancelled by newer call
updateResults(result);
asyncDebouncer.dispose();

Server-side Batching #

final batcher = BatchThrottler(
  duration: Duration(seconds: 1),
  onBatchExecute: (actions) async {
    final logs = actions.map((a) => a()).toList();
    await database.insertAll(logs);
  },
);
batcher.add(() => 'User logged in');
batcher.add(() => 'Page viewed');
// After 1 second, all logs inserted in single batch
batcher.dispose();

Available Classes #

Sync Controllers #

  • Throttler: Immediate execution, blocks for duration
  • Debouncer: Delayed execution after pause
  • HighFrequencyThrottler: Optimized for scroll/resize (no Timer overhead)
  • ThrottleDebouncer: Leading + trailing edge execution

Async Controllers #

  • AsyncThrottler: Lock-based async throttle
  • AsyncDebouncer: Debounce with auto-cancel for async operations
  • ConcurrentAsyncThrottler: Advanced async with drop/enqueue/replace/keepLatest modes

Utilities #

  • BatchThrottler: Batch multiple actions for bulk execution
  • DebounceThrottleConfig: Global configuration
  • EventLimiterLogger: Centralized logging

Configuration #

void main() {
  DebounceThrottleConfig.init(
    defaultDebounceDuration: Duration(milliseconds: 300),
    defaultThrottleDuration: Duration(milliseconds: 500),
    enableDebugLog: true,
  );

  // Your app code...
}
0
likes
0
points
194
downloads

Publisher

verified publisherbrewkits.dev

Weekly Downloads

Pure Dart core for flutter_debounce_throttle. Zero external dependencies. Debounce, throttle, and rate limit with no Flutter dependency. Works on Mobile, Web, Desktop, Server, and CLI.

Repository (GitHub)
View/report issues

Topics

#debounce #throttle #rate-limiting #async #dart

License

unknown (license)

Dependencies

meta

More

Packages that depend on flutter_debounce_throttle_core