Reputation: 21
I have used .where on the List to filter like this:-
List<AppUsageInfo> get eyes => (_appInfo.where((element)=>element.packageName=='apple')).toList();
This works but I want to filter with more than just one word. When I try the following code:
List<AppUsageInfo> get eyes => (_appInfo.where((element)=>element.packageName=='apple'||'google')).toList();
I get the error 'The operands of the operator '||' must be assignable to 'bool.'
I tried using brackets around 'apple and 'google' to see if it changes anything but that didn't seem to work. Any help would me much appreciated!
Upvotes: 0
Views: 651
Reputation: 7100
Use this
List<AppUsageInfo> get eyes =>
_appInfo.where((element)=>['apple', 'google'].contains(element.packageName)).toList();
Upvotes: 1
Reputation:
The operator ||
accepts only booleans for both of the operands of the operator.
_appInfo.where((element) => element.packageName == 'apple' || element.packageName == 'google').toList()
Upvotes: 0