本文介绍了如何从颤动的触点中选择单个触点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直被这个问题困扰.如何从flutter中的联系人中选择和获取详细信息?请帮忙.

I have been stuck on this problem. How to select and fetch details from a contact in flutter? Please ​help.

推荐答案

添加此依赖项

这是当前的当前版本

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

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

class MyApp extends StatefulWidget {
 @override
_MyAppState createState() => new _MyAppState();
}

 class _MyAppState extends State<MyApp> {
  final ContactPicker _contactPicker = new ContactPicker();
  Contact _contact;

  @override
  Widget build(BuildContext context) {
   return new MaterialApp(
   home: new Scaffold(
    appBar: new AppBar(
       title: new Text('Plugin example app'),
     ),
      body: new Center(
      child: new Column(
        mainAxisSize: MainAxisSize.min,
         children: <Widget>[
          new MaterialButton(
            color: Colors.blue,
            child: new Text("CLICK ME"),
            onPressed: () async {
              Contact contact = await _contactPicker.selectContact();
              setState(() {
                _contact = contact;
              });
            },
          ),
          new Text(
            _contact == null ? 'No contact selected.' : _contact.toString(),
          ),
        ],
      ),
    ),
  ),
);
 }
}

这篇关于如何从颤动的触点中选择单个触点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 05:10