flutter_native_contact_picker 0.0.8-prerelease copy "flutter_native_contact_picker: ^0.0.8-prerelease" to clipboard
flutter_native_contact_picker: ^0.0.8-prerelease copied to clipboard

A Flutter plugin for picking a contact from the address book.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
import 'package:flutter_native_contact_picker/model/contact.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 FlutterNativeContactPicker _contactPicker = FlutterNativeContactPicker();
  List<Contact>? _contacts;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Contact Picker Example App'),
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              MaterialButton(
                color: Colors.blue,
                child: const Text("Single"),
                onPressed: () async {
                  Contact? contact = await _contactPicker.selectContact();
                  setState(() {
                    _contacts = contact == null ? null : [contact];
                  });
                },
              ),
              MaterialButton(
                color: Colors.blue,
                child: const Text("Multiple"),
                onPressed: () async {
                  // final contacts = await _contactPicker.selectContacts();
                  // setState(() {
                  //   _contacts = contacts;
                  // });
                },
              ),
              if (_contacts != null)
                ..._contacts!.map(
                      (e) => Text(e.toString()),
                )
            ],
          ),
        ),
      ),
    );
  }
}
52
likes
0
points
8.47k
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for picking a contact from the address book.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_native_contact_picker