flutter_debouncer 1.2.1 copy "flutter_debouncer: ^1.2.1" to clipboard
flutter_debouncer: ^1.2.1 copied to clipboard

A Flutter plugin for debouncing can be used to simplify the implementation of debouncing logic in Flutter applications, making it easier to handle user interactions effectively.

Flutter Debouncer #

A Flutter plugin for debouncing can be used to simplify the implementation of debouncing logic in Flutter applications. It provides a convenient way to handle debouncing scenarios for user interactions, such as button presses or text input changes, in order to enhance the user experience and avoid unintended actions or frequent updates.

Features #

✅   Debouncing
✅   Throttling

Demo #

Quick Start #

Step 1: Include the package to your project #

dependencies:
  flutter_debouncer: <latest version>

Run pub get and get packages.

Step 2: Add this package to your project #

import 'package:flutter_debouncer/flutter_debouncer.dart';

Step 3: Initialize Debouncer #

final Debouncer _debouncer = Debouncer();

Example #

Debouncing #

void _handleTextFieldChange(String value) {
    _debouncer.debounce(const Duration(milliseconds: 500), () {
      setState(() {
        debouncedText = value;
      });
    });
  }

Debouncing with leading edge #

Callback function is immediately executed at the beginning of the debounce duration.

void _handleTextFieldChange(String value) {
    _debouncer.debounce(
      const Duration(milliseconds: 500),
      () {
        setState(() {
          debouncedText = value;
        });
      },
      ///Set [isLeadingEdge] parameter to [true]
      isLeadingEdge: true,
    );
  }

Throttling #

void _handleTextFieldChange(String value) {
    _debouncer.throttle(const Duration(milliseconds: 500), () {
      setState(() {
        throttledCounter++;
       });
    });
  }

Project Created & Maintained By #

Syaif Akmal #

     

License #

Code released under the GNU GENERAL PUBLIC LICENSE Version 3.

9
likes
0
pub points
92%
popularity

Publisher

unverified uploader

A Flutter plugin for debouncing can be used to simplify the implementation of debouncing logic in Flutter applications, making it easier to handle user interactions effectively.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flutter_debouncer