This commit is contained in:
Hillel Coren 2020-02-17 22:36:12 +02:00
parent 72156b5017
commit 3e7e34f15a
2 changed files with 22 additions and 3 deletions

View File

@ -553,8 +553,13 @@ class ReportResult {
return true;
}
static bool matchString({String filter, String value}) =>
matchesString(value, filter);
static bool matchString({String filter, String value}) {
if (filter == null || filter.isEmpty) {
return true;
}
return value.toLowerCase().contains(filter.toLowerCase());
}
static bool matchAmount({String filter, double amount}) {
final String range = filter.replaceAll(',', '-') + '-';

View File

@ -44,11 +44,25 @@ String getLastName(String value) {
return parts.last;
}
bool matchesStrings(List<String> haystacks, String needle) {
bool isMatch = false;
haystacks.forEach((haystack) {
if (matchesString(haystack, needle)) {
isMatch = true;
}
});
return isMatch;
}
bool matchesString(String haystack, String needle) {
if (needle == null || needle.isEmpty) {
return true;
}
String regExp = '';
needle.toLowerCase().runes.forEach((int rune) {
final character = String.fromCharCode(rune);
regExp += character + '.*?';
});
return RegExp(regExp).hasMatch(haystack.toLowerCase());
}
}