contacts_provider 0.1.2 copy "contacts_provider: ^0.1.2" to clipboard
contacts_provider: ^0.1.2 copied to clipboard

Flutter package for observing contact changes, and providing onDelete, onCreate, onUpdate and onChange events.

Under development #

contacts_provider #

add these to android manifest file:

    <uses-permission android:name="android.permission.READ_CONTACTS" />  
    <uses-permission android:name="android.permission.WRITE_CONTACTS" /> 

/main.dart initializing the contacts and asking for permissions.
You can ask for the permissions wherever you like, it is just for the demonstration purposes.

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  
  // initializing contacts_provider
  final contacts = Contacts();
  await contacts.handlePermissions();
  await contacts.init();

  runApp(const MainApp());
}

/home.dart


class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ContactsBuilder(
      onCreate: (event) {
        // on create behavior goes here

        // you can access the event from here.

        // new contact list after event has happened
        event.contactList;

        // only effected contact list, in case of create
        // it will be the contacts that were created
        event.effectedContacts;
        // event type
        event.event;
      },
      onUpdate: (event) {
        // on update behavior goes here
      },
      onDelete: (event) {
        // on delete behavior goes here
      },
      onChange: () {
        // If you specify this, it will be executed on any changes will happen in contacts;
      },
      builder: (context, data) {
        // receive new list of contacts here.
        final allContacts = data.contactList;
        return ListView.builder(
          itemCount: allContacts.length,
          itemBuilder: (BuildContext context, int index) {
            final contact = allContacts[index];
            return ContactListTile(contact: contact);
          },
        );
      },
    );
  }
}

1
likes
0
pub points
36%
popularity

Publisher

unverified uploader

Flutter package for observing contact changes, and providing onDelete, onCreate, onUpdate and onChange events.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

contacts_service, flutter, listentocontacts, permission_handler, rxdart, shared_preferences

More

Packages that depend on contacts_provider