free_contact_picker 1.0.0
free_contact_picker: ^1.0.0 copied to clipboard
Flutter plugin for picking contact on Android/iOS without any permission.
import 'package:flutter/material.dart';
import 'package:free_contact_picker/free_contact_picker.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final _contactPickerPlugin = FreeContactPicker();
String _contactName = '';
String _contactPhone = '';
void pickContact() {
_contactPickerPlugin.pickContact(
(contact) {
setState(() {
_contactName = contact['name'];
_contactPhone = contact['phone'];
});
},
onError: (error) {
debugPrint(error);
},
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Plugin example app')),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text('ContactName: $_contactName'),
Text('ContactPhone: $_contactPhone'),
FilledButton(onPressed: pickContact, child: Text('Pick Contact')),
],
),
),
),
);
}
}