简体   繁体   English

Flutter 联系人_服务包使用

[英]Flutter contacts_service package use

I am using https://pub.dev/packages/contacts_service .我正在使用https://pub.dev/packages/contacts_service I am able to do:我能够做到:

contacts.forEach((contact){
      print(contact.displayName);
});

How do I print items of contact.emails ?如何打印 contact.emails 的项目? They are defined as Iterable它们被定义为可迭代的

Try this;尝试这个;

contacts.forEach((contact) {
  print(contact.displayName);
  contact.emails.forEach((item) {
    print(item.value);
  });
});

Emails are stored in a label: value format in that lib.电子邮件存储在该库中的 label: value 格式中。 This should work:这应该有效:

      contacts.forEach((contact) {
        print('Name: ${contact.displayName}');
        for (var email in contact.emails) {
          print('Email: ${email.label} => ${email.value}');
        }
      });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM