Created
June 20, 2020 22:45
-
-
Save danahartweg/b3915479050d17f1c063b9d283af46a1 to your computer and use it in GitHub Desktop.
ItemListBloc searchSource - Manage lists with Flutter Bloc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Iterable<I> _searchSource(String searchQuery, Iterable<I> items) { | |
if (searchQuery.isEmpty) { | |
return items; | |
} | |
// Search queries are stored lowercase, so we want to match | |
// against a lowercase value as well. | |
return items.where((item) => _searchProperties.any((property) { | |
final value = item[property]; | |
return value is String | |
? value.toLowerCase().contains(searchQuery) | |
: false; | |
})); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment