2024-10-26 20:53:30 +00:00
|
|
|
import 'package:flutter_contacts/flutter_contacts.dart';
|
|
|
|
|
|
|
|
// Service to manage contact-related operations
|
|
|
|
class ContactService {
|
|
|
|
Future<List<Contact>> fetchContacts() async {
|
|
|
|
if (await FlutterContacts.requestPermission()) {
|
|
|
|
return await FlutterContacts.getContacts(withProperties: true, withThumbnail: true);
|
|
|
|
}
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> addNewContact(Contact contact) async {
|
|
|
|
await FlutterContacts.insertContact(contact);
|
|
|
|
}
|
2024-11-06 15:27:38 +00:00
|
|
|
|
|
|
|
Future<void> toogleFavorite(Contact contact) async {
|
|
|
|
contact.isStarred = !contact.isStarred;
|
|
|
|
await FlutterContacts.updateContact(contact);
|
|
|
|
}
|
2024-10-26 20:53:30 +00:00
|
|
|
}
|