whereStartsWith method

void whereStartsWith(
  1. String key,
  2. String prefix, {
  3. bool caseInsensitive = false,
})

Add a constraint for finding string values that start with a provided string.

This query will use the backend index, so it will be fast even for large datasets.

Implementation

void whereStartsWith(String key, String prefix,
    {bool caseInsensitive = false}) {
  String regex = RegExp.escape(prefix);
  regex = "${caseInsensitive ? "(?i)" : ""}^$regex";
  whereMatches(key, regex);
}