searchValues method

Map searchValues(
  1. String valuePrefix
)

Gives suggested auto-complete values from this box, along with corresponding keys. Suggested values are sorted by number of occurrences in this box.

If all keys are not String, this will instead call the toString() method of non-String keys and search the results.

Suggestions are returned in a Map, where:

  • The keys are the correspondent keys to the autocomplete suggestions.
  • The values are the autocomplete suggestions.

Implementation

Map searchValues(String valuePrefix) {
  var valList = values.map((e) => e.toString()).toList();
  var _engineValues =
      AutoComplete(engine: SortEngine.entriesOnly(), bank: valList);
  var valuesuggest = _engineValues.suggest(valuePrefix);
  var map = toMap();
  map.removeWhere((dynamic key, dynamic val) {
    return !valuesuggest.contains(val.toString());
  });
  return map;
}