case insensitive search + onion search only from start #151

Merged
sarah merged 1 commits from searchFix into trunk 2021-06-04 04:22:06 +00:00
1 changed files with 2 additions and 2 deletions

View File

@ -64,13 +64,13 @@ class ContactListState extends ChangeNotifier {
bool get isFiltered => _filter != ""; bool get isFiltered => _filter != "";
String get filter => _filter; String get filter => _filter;
set filter(String newVal) { set filter(String newVal) {
_filter = newVal; _filter = newVal.toLowerCase();
notifyListeners(); notifyListeners();
} }
List<ContactInfoState> filteredList() { List<ContactInfoState> filteredList() {
if (!isFiltered) return contacts; if (!isFiltered) return contacts;
return _contacts.where((ContactInfoState c) => c.onion.contains(_filter) || (c.nickname.contains(_filter))).toList(); return _contacts.where((ContactInfoState c) => c.onion.toLowerCase().startsWith(_filter) || (c.nickname.toLowerCase().contains(_filter))).toList();
} }
void addAll(Iterable<ContactInfoState> newContacts) { void addAll(Iterable<ContactInfoState> newContacts) {