Skip to content

Instantly share code, notes, and snippets.

@alperefesahin
Created January 8, 2023 13:19
Show Gist options
  • Save alperefesahin/0a229113b820449bbba4e19fbfdeabb5 to your computer and use it in GitHub Desktop.
Save alperefesahin/0a229113b820449bbba4e19fbfdeabb5 to your computer and use it in GitHub Desktop.
bool searchInsideExistingChannels({
required List<Channel> listOfChannels,
required String searchedText,
required int index,
required int lengthOfTheChannelMembers,
required User oneToOneChatMember,
}) {
int result;
final editedSearchedText = searchedText.toLowerCase().trim();
if (lengthOfTheChannelMembers == 2) {
final filteredChannels = listOfChannels
.where(
(channel) => oneToOneChatMember.name.toLowerCase().trim().contains(editedSearchedText),
)
.toList();
result = filteredChannels.indexOf(listOfChannels[index]);
} else {
final filteredChannels = listOfChannels
.where(
(channel) => channel.name!.toLowerCase().trim().contains(editedSearchedText),
)
.toList();
result = filteredChannels.indexOf(listOfChannels[index]);
}
if (result == -1) {
return false;
} else {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment