together_mobile/lib/utils/search_local_friend.dart

19 lines
703 B
Dart

import '/models/init_get_it.dart' show getIt;
import '/models/contact_model.dart' show ContactAccountProfile, Contact;
import '/models/user_model.dart' show UserAccount;
List<String> searchLocalFriend(String value) {
final id = getIt.get<UserAccount>().id;
List<String> matchFriendIds = [];
getIt.get<ContactAccountProfile>().friends.forEach((key, accountProfile) {
if ((accountProfile.email.contains(value) ||
accountProfile.username.contains(value) ||
accountProfile.nickname.contains(value) ||
getIt.get<Contact>().friends[key]!.friendRemark.contains(value)) &&
key != id) {
matchFriendIds.add(key);
}
});
return matchFriendIds;
}