Debounce class

A simple class to debounce function execution.

final Debounce _debounce = Debounce(milliseconds: 300);
final TextEditingController _controller = TextEditingController();

@override
void dispose() {
  _debounce.dispose();
  _controller.dispose();
  super.dispose();
}

TextField(
  controller: _controller,
  decoration: InputDecoration(
    labelText: 'Search',
  ),
  onChanged: (value) {
    _debounce.run(_onSearchChanged);
  },
),

Constructors

Debounce({int milliseconds = kDefaultDebounceTime})
A simple class to debounce function execution.

Properties

hashCode int
The hash code for this object.
no setterinherited
milliseconds int
The delay in milliseconds.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Disposes the timer if it is active.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run(VoidCallback action) → void
Runs the action after the specified milliseconds delay.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited