contact_access_kit 0.0.2
contact_access_kit: ^0.0.2 copied to clipboard
A Flutter plugin to pick a contact and retrieve name, phone number, and email from device contacts.
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"] ?? ""}'),
]
],
),
),
),
);
}
}