Debounce API calls or Expensive Operations.

Features

You can use it for debouncing onChanged of TextField.

Getting started

To install the package run following command:

flutter pub add debounce_hook

Usage

Common useage as follows.

class MyWidget extends HookWidget {
  const MyWidget({super.key});

  @override
  Widget build(BuildContext context) {
    final debounce = useDebounce<String>(
      // in milliseconds
      debounceDelay: 500,
      callback: (value) {
        // do API call or a expensive computation
      },
    );

    return TextField(
      onChanged: (value) {
        // Common example of using debounce is using `onChanged` of
        // `TextField`.
        debounce.onChanged(value);
      },
    );
  }
}

Libraries

debounce_hook