fetchContacts method
Implementation
Future<List<AtContact?>> fetchContacts() async {
selectedContacts = [];
try {
contactList = [];
allContactsList = [];
contactList = await atContactImpl.listContacts();
var tempContactList = <AtContact?>[...contactList];
var range = contactList.length;
for (var i = 0; i < range; i++) {
allContactsList.add(contactList[i]!.atSign!);
if (contactList[i]!.blocked!) {
tempContactList.remove(contactList[i]);
}
}
contactList = tempContactList;
contactList.sort((a, b) {
// ignore: omit_local_variable_types
int? index = a?.atSign
.toString()
.substring(1)
.compareTo(b!.atSign!.toString().substring(1));
return index!;
});
contactSink.add(contactList);
return contactList;
} catch (e) {
print('error here => $e');
return [];
}
}