textSearch method

List<T> textSearch(
  1. String query,
  2. Iterable<String> test(
    1. T e
    )
)

Implementation

List<T> textSearch(String query, Iterable<String> Function(T e) test) {
  final List<T> items = [];
  final String queryNormalized = query.toNormalize();
  for (final T item in this) {
    for (final String text in test(item)) {
      if (text.toNormalize().contains(queryNormalized)) {
        items.add(item);
        break;
      }
    }
  }
  return items;
}