updateSearch method

void updateSearch(
  1. String value
)

Debounces a trimmed search value before issuing a query load.

An unchanged committed string is ignored; empty text clears search. This method preserves pagination unless the constructor's query mapper resets it. Returning to the committed search cancels an outstanding debounce.

Implementation

void updateSearch(String value) {
  final normalized = value.trim();
  _searchTimer?.cancel();
  if ((_query.search ?? '') == normalized) return;
  _searchTimer = Timer(searchDebounce, () {
    _query =
        _queryForSearch?.call(_query, normalized) ??
        (normalized.isEmpty
            ? _query.copyWith(clearSearch: true)
            : _query.copyWith(search: normalized));
    _run(CollectionRequestReason.query);
  });
}