Search packages, repositories and app categories

Package detailsv2.0.0

debounce_throttle

A debouncer and throttle that works with Futures, Streams, and callbacks.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
199K
Likes
75
Pub points
160

Install package

flutter pub add debounce_throttle

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A lightweight Dart package providing debouncing and throttling functionality for asynchronous operations, including Futures, Streams, and callbacks. It helps manage high-frequency events—such as user input or network requests—by delaying or limiting execution to improve performance and reduce resource usage. Ideal for optimizing search inputs, resize handlers, and real-time form validation. The package is platform-agnostic and integrates seamlessly into Flutter applications across Android, iOS, Web, macOS, Windows, and Linux.

Use cases

  • Optimizing search input delays
  • Reducing rapid API calls
  • Managing real-time form validation
  • Handling window resize events
  • Improving scroll performance
  • Controlling button click rate

Key features

  • Supports Futures, Streams, and callbacks
  • Cross-platform compatibility
  • Simple and intuitive API
  • Configurable delay and throttle intervals
  • No external dependencies
  • Thread-safe operations

Suitable for

  • Developers building responsive UIs
  • Apps with frequent user interactions
  • Performance-critical applications
  • Real-time data processing
  • Flutter apps targeting multiple platforms

Considerations

  • Requires understanding of async programming
  • May introduce latency in time-sensitive operations
  • Not suitable for immediate response scenarios
  • Needs careful tuning of delay values
  • Limited to event rate limiting use cases
  • Does not handle complex state management

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

debounce_throttle

A debouncer and throttle that works with Future, Stream, and callbacks.

Class Purpose
Debouncer Wait for changes to stop before notifying.
Throttle Notifies once per Duration for a value that keeps changing.

Usage

  final debouncer = Debouncer<String>(Duration(milliseconds: 200));

  // Run a search whenever the user pauses while typing.
  textEditingController.addListener(() => debouncer.value = textEditingController.text);
  debouncer.values.listen((search) => submitSearch(search));

  final throttle = Throttle<double>(Duration(milliseconds: 100));

  // Limit being notified of continuous sensor data.
  sensor.addListener(throttle.setValue);
  throttle.values.listen((data) => print('$data'));

example/main.dart output

Tick     : ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed  : -----------     -  --   - -  -    --  - -    -   -    -  -   - ---  -  - -  - -    -    -    - - - - --    -    -  -   - - -   --    - --    ---    -   -  - -     -    -     -  -  -
Debounced:              D     D   D     D  D          D    D   D    D  D          D         D    D    D             D    D    D  D       D    D       D      D    D        D     D    D     D
Throttled: T  T  T  T  T   T  T  T  T   T  T  T  T  T   T   T    T  T   T  T  T  T  T  T  T   T    T    T  T  T  T  T  T   T  T   T  T  T  T  T  T  T   T  T   T   T  T  T    T    T     T  T  T

Categories

Dependencies

Dependency list 2 items

Source repository

Projects using this package