flutter - 更改Flutter中与contacts_service的联系人的电话号码和显示名称

标签 flutter dart

我正在尝试使用flutter contact_service dart软件包更新我的单个联系人数据。我是Flutter编程的新手,这就是为什么不明白我该怎么做的原因。
那是我的代码。

enter code here
 await ContactsService.updateContact(
            Contact(displayName: "yello", phones: abcd))
        .catchError((onError) {
      print(onError.toString());
    });

最佳答案

试试这个

/*this line fetches the contact whose familyName(last name) is "Jackson", incase 
if there's multiple contact with the same familyName then it'll select first one */
Contact contactToUpdate = _contacts
        .toList()
        .firstWhere((contact) => contact.familyName.startsWith("Jackson"));
//this line updates the givenName(first name) of fetched contact to "Michael"
    contactToUpdate.givenName = 'Michael';
    await ContactsService.updateContact(contactToUpdate);

关于flutter - 更改Flutter中与contacts_service的联系人的电话号码和显示名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62772321/

相关文章:

ios - 如何使用flutter,wordpress在我的应用程序中添加拉动刷新?

dart - 如何防止多行文本小部件放置在行中时被剪裁?

flutter - 如何在 Flutter 中格式化日期时间?删除 DateTime 中的毫秒数?

dart - 无法安装flutter_plugins_tools,依赖错误

flutter - http.dart onError : Invalid argument (onError): Error handler must accept one Object or one Object and a StackTrace as arguments 的无效参数

asynchronous - Stream.last 回调从不触发

dart - 如何使用 Dart 语言获取所有子元素的数组?

firebase - flutter firebase auth 应用栏标题的当前用户电子邮件

node.js - 在 Flutter 中使用 npm 包

flutter - Flutter:如何在CustomPainter对象中设置动态颜色