searchTeam method
查询群组
Implementation
Future<List<TeamSearchInfo>> searchTeam(String text) async {
var teamList =
await await NimCore.instance.teamService.searchTeamByKeyword(text);
if (teamList == null || teamList.data == null) {
return List.empty();
} else {
List<TeamSearchInfo> resultList = List.empty(growable: true);
for (var team in teamList.data!) {
var hit = TextSearcher.search(team.name ?? '', text);
if (hit != null && team.isValidTeam) {
resultList.add(TeamSearchInfo(
team: team, hitInfo: hit, hitType: HitType.teamName));
continue;
}
}
resultList.sort((a, b) {
if (getIt<TeamProvider>().isGroupTeam(a.team)) {
return 1;
} else {
return -1;
}
});
return resultList;
}
}