Skip to content

Instantly share code, notes, and snippets.

@folaoluwafemi
Last active July 8, 2023 22:40
Show Gist options
  • Save folaoluwafemi/7d2360b017cb593e93b008cc07828f6a to your computer and use it in GitHub Desktop.
Save folaoluwafemi/7d2360b017cb593e93b008cc07828f6a to your computer and use it in GitHub Desktop.
A method for comparing queries in dart
abstract final class UtilFunctions {
static bool compareQueries(String value, String query) {
final String formattedValue = value.trim().toLowerCase();
final List<String> queryWords = query.split(' ');
if (queryWords.length == 1) {
return formattedValue.contains(query.trim().toLowerCase());
}
bool hasMatch = false;
for (String queryWord in queryWords) {
hasMatch = formattedValue.contains(queryWord.trim().toLowerCase());
if (hasMatch) return true;
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment