Created
June 20, 2020 22:39
-
-
Save danahartweg/e16197e45d5b9f24c74d7f6a6f833879 to your computer and use it in GitHub Desktop.
ItemListBloc filterSource - 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> _filterSource(List<I> items) { | |
final activeConditions = | |
(_filterConditionsBloc.state as ConditionsInitialized).activeConditions; | |
if (activeConditions.isEmpty) { | |
return items; | |
} | |
// If any active condition matches we can immediately return that item. | |
return items.where((item) => activeConditions.any((conditionKey) { | |
final conditionKeyValue = splitConditionKey(conditionKey); | |
return item[conditionKeyValue[0]] == conditionKeyValue[1]; | |
})); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment