我正在尝试使用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/