cancel static method

dynamic cancel(
  1. BuildContext context, {
  2. String? debouncerKey,
})

Attempts to find and cancel the action located in a parent widget. context should be the BuildContext of a child widget to a Debouncer widget. debouncerKey is an optional key that can be used to find a specific Debouncer widget if multiple parent Debouncers exist.

Implementation

static cancel(BuildContext context, {String? debouncerKey}) {
  final elToExecute = Debouncer.findDebouncerWidget(
    context,
    debouncerKey: debouncerKey,
  );

  if (elToExecute == null) {
    throw NoDebouncerFoundException('No Debouncer parent object present');
  }

  elToExecute.cancel();
}