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