G-EIP-700-TLS-7-1-eip-steph.../dialer/lib/features/contacts/contact_service.dart

20 lines
610 B
Dart
Raw Permalink Normal View History

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);
}
Future<void> toogleFavorite(Contact contact) async {
contact.isStarred = !contact.isStarred;
await FlutterContacts.updateContact(contact);
}
2024-10-26 20:53:30 +00:00
}