debounceOnValueChangedIfNeeded method

  1. @protected
ValueChanged<String>? debounceOnValueChangedIfNeeded()

Implementation

@protected
ValueChanged<String>? debounceOnValueChangedIfNeeded() {
  if (widget.isEnabled && widget.onValueChanged != null) {
    if (widget.shouldDebounceTime) {
      subscribeToDebouncerEvents();

      return (String value) {
        return debouncer.add(() => widget.onValueChanged!(value));
      };
    }

    unsubscribeToDebouncerEventsIfNeeded();

    return widget.onValueChanged;
  }

  unsubscribeToDebouncerEventsIfNeeded();

  return null;
}