Created
January 8, 2023 13:19
-
-
Save FlutterWiz/0a229113b820449bbba4e19fbfdeabb5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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