query method

List<UDocRecord> query({
  1. String? text,
  2. UDocKind? kind,
  3. bool favoritesOnly = false,
  4. String? collection,
})

Implementation

List<UDocRecord> query({String? text, UDocKind? kind, bool favoritesOnly = false, String? collection}) {
  final String needle = UDocText.forSearch(text ?? "");
  return _records.where((UDocRecord record) {
    if (kind != null && record.kind != kind) return false;
    if (favoritesOnly && !record.favorite) return false;
    if (collection != null && !record.collections.contains(collection)) return false;
    if (needle.isEmpty) return true;
    final String haystack = UDocText.forSearch("${record.displayTitle} ${record.metadata.author ?? ""} ${record.fileName}");
    return haystack.contains(needle);
  }).toList();
}