Skip to content

Commit

Permalink
lint/fix quick start code
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimvalente committed Apr 11, 2021
1 parent 543a6b9 commit 81d72d3
Showing 1 changed file with 36 additions and 35 deletions.
71 changes: 36 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,42 @@ import 'package:flutter_contacts/flutter_contacts.dart';
// Request contact permission
if (await FlutterContacts.requestPermission()) {
// Get all contacts (lightly fetched)
List<Contact> contacts = await FlutterContacts.getContacts();
// Get all contacts (fully fetched)
List<Contact> contacts = await FlutterContacts.getContacts(withProperties: true, withPhoto: true);
// Get contact with specific ID (fully fetched)
Contact contact = await FlutterContacts.getContact(contacts.first.id)
// Insert new contact
await Contact()
..name.first = 'John'
..name.last = 'Smith'
..phones = [Phone('555-123-4567')]
..insert();
// Update contact
contact.name.first = 'Bob';
await contact.update();
// Delete contact
await contact.delete();
// Listen to contact database changes
FlutterContacts.addListener(() => print('Contact DB changed'));
// Export contact to vCard
String vCard = contact.toVCard();
// Import contact from vCard
Contact contact = Contact.fromVCard('BEGIN:VCARD\n'
'VERSION:3.0\n'
'N:;Joe;;;\n'
'TEL;TYPE=HOME:123456\n'
'END:VCARD');
// Get all contacts (lightly fetched)
List<Contact> contacts = await FlutterContacts.getContacts();
// Get all contacts (fully fetched)
contacts = await FlutterContacts.getContacts(
withProperties: true, withPhoto: true);
// Get contact with specific ID (fully fetched)
Contact contact = await FlutterContacts.getContact(contacts.first.id);
// Insert new contact
final newContact = Contact()
..name.first = 'John'
..name.last = 'Smith'
..phones = [Phone('555-123-4567')];
await newContact.insert();
// Update contact
contact.name.first = 'Bob';
await contact.update();
// Delete contact
await contact.delete();
// Listen to contact database changes
FlutterContacts.addListener(() => print('Contact DB changed'));
// Export contact to vCard
String vCard = contact.toVCard();
// Import contact from vCard
contact = Contact.fromVCard('BEGIN:VCARD\n'
'VERSION:3.0\n'
'N:;Joe;;;\n'
'TEL;TYPE=HOME:123456\n'
'END:VCARD');
}
```

Expand Down

0 comments on commit 81d72d3

Please sign in to comment.