contact_access_kit 0.0.2 copy "contact_access_kit: ^0.0.2" to clipboard
contact_access_kit: ^0.0.2 copied to clipboard

PlatformAndroid

A Flutter plugin to pick a contact and retrieve name, phone number, and email from device contacts.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:contact_access_kit/contact_access_kit.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Map? _contactData;

  Future<void> _pickContact() async {
    /*
      IMPORTANT:
      This plugin does NOT handle permissions.

      You must request contact permission before calling this method.
      Recommended package:
      permission_handler

      Example:
      await Permission.contacts.request();
    */

    final contact = await ContactAccessKit.pickContact();

    if (contact != null) {
      setState(() {
        _contactData = contact;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Contact Access Kit Example'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(
                onPressed: _pickContact,
                child: const Text('Pick Contact'),
              ),
              const SizedBox(height: 20),
              if (_contactData != null) ...[
                Text('Name: ${_contactData!["name"] ?? ""}'),
                Text('Phone: ${_contactData!["phone"] ?? ""}'),
                Text('Email: ${_contactData!["email"] ?? ""}'),
              ]
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
160
points
96
downloads

Documentation

API reference

Publisher

verified publishermohsinpatel.online

Weekly Downloads

A Flutter plugin to pick a contact and retrieve name, phone number, and email from device contacts.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on contact_access_kit

Packages that implement contact_access_kit