Open davidmednikov opened 4 years ago
@davidmednikov it is not easy to implement
I was able to implement it the following way:
In suggestions_textfield.dart
, line 154 and 155 currently do:
_matches = _suggestions.where((String sgt) => sgt.startsWith(str)).toList();
I replaced this with:
_matches = _suggestions.where((String sgt) => sgt.toLowerCase().startsWith(str.toLowerCase())).toList();
_matches = _matches.map((match) => match.replaceFirst(match.substring(0, str.length), str)).toList();
Then, for the TagsTextField
widget:
textField: TagsTextField(
duplicates: true,
...
onSubmitted: (newTagStr) {
String tagName = suggestions.firstWhere((suggestion) => suggestion.toLowerCase() == newTagStr.toLowerCase(), orElse: () => null);
if (tagName != null) {
newTagStr = tagName;
}
if (!tags.map((tag) => tag.title.toLowerCase()).toList().contains(newTagStr.toLowerCase())) {
setState(() {
tags.add(Item(
index: tags.length,
title: newTagStr,
active: true,
customData: true
));
});
}
}
}
@davidmednikov yours is a great job! I just wanted to avoid adding all this logic when instead a good practice would be to avoid upstream the use of contemporary uppercase and lowercase text in the suggestions. However, I will take your work into consideration, and carry out checks.
Is it possible to make the suggestions matching non-case-sensitive?
lowerCase
prop and applyingtoLowerCase()
to the suggestions has not worked.