roomSearchedChatsProvider top-level property
final
Implementation
final roomSearchedChatsProvider =
FutureProvider.autoDispose<List<String>>((ref) async {
final allRoomList = await ref.watch(_briefGroupChatsWithName.future);
final foundRooms = List<String>.empty(growable: true);
final searchValue = ref.watch(roomSearchValueProvider);
if (searchValue == null || searchValue.isEmpty) {
return allRoomList.map((item) {
final (roomId, dispName) = item;
return roomId;
}).toList();
}
final loweredSearchValue = searchValue.toLowerCase();
for (final (roomId, dispName) in allRoomList) {
if (roomId.toLowerCase().contains(loweredSearchValue) ||
(dispName ?? '').toLowerCase().contains(loweredSearchValue)) {
foundRooms.add(roomId);
}
}
return foundRooms;
});