filteredSuggestedUsersProvider top-level property
final
Implementation
final filteredSuggestedUsersProvider =
FutureProvider.family<List<UserProfile>, String?>((ref, roomId) async {
final newSearchValue = ref.watch(userSearchValueProvider);
final suggestedUsers =
ref.watch(suggestedUsersProvider(roomId)).valueOrNull ?? [];
if (newSearchValue == null || newSearchValue.isEmpty) {
// no search value: shows all
return suggestedUsers;
}
final loweredSearchValue = newSearchValue.toLowerCase();
return suggestedUsers.where(
(profile) {
if (profile
.userId()
.toString()
.toLowerCase()
.contains(loweredSearchValue)) {
return true;
}
return profile
.displayName()
?.toLowerCase()
.contains(loweredSearchValue) ==
true;
},
).toList();
});