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

A package for creating debounce in dart will possibilities of multi instances debounce. No singleton pattern

How to use #

First, instanciate a Debouncer class.

final Debouncer debouncer = Debouncer();

Then, in any place, use it.

TextFormField(
  ...
  onChanged: (final String text) {
    decouncer.resetDebounce(() {
      // Do something with the text
    });
  },
),

Don't forget to dispose the debounce timer after using it #

debouncer.dispose();

Otherwise it will be executed even if you are not more in the context where it has been placed.

Other helpfull functions #

Add a function that will be executed before debounce execute function #

You can add how many functions you want. They will run in the order they where added.

debouncer.addOnInitFunction(() {
    print('start 1');
});
debouncer.addOnInitFunction(() {
    print('start 2');
});

Add a function that will be executed after debounce execute function #

You can add how many functions you want. They will run in the order they where added.

debouncer.addOnEndFunction(() {
    print('end 1');
});
debouncer.addOnEndFunction(() {
    print('end 2');
});

Change debounce duration #

// The debouncer time is 1 sec
final debouncer = Debouncer(timerDuration: Duration(seconds: 1));

// Now the timer is 3 secs
debounder.updateTimer(Duration(seconds: 3));

Duration extensions #

Extension methods for num, to make specifying durations easier. For example: 2.seconds, 0.1.minutes, or 300.ms.


Made with ❤ by Igor Miranda
If you like the package, give a 👍

5
likes
0
pub points
67%
popularity

Publisher

unverified uploader

A package for creating debounce in dart will possibilities of multi instances debounce. No singleton pattern

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on dart_debouncer