extractOne<T> method

ExtractedResult<T> extractOne<T>(
  1. String query,
  2. List<T> choices,
  3. Applicable func, [
  4. String getter(
    1. T obj
    )?,
])

Find the single best match above a score in a list of choices

Implementation

ExtractedResult<T> extractOne<T>(
  String query,
  List<T> choices,
  Applicable func, [
  String Function(T obj)? getter,
]) {
  var extracted = extractWithoutOrder(query, choices, func, getter);

  return extracted.reduce(
    (value, element) => value.score > element.score ? value : element,
  );
}