[英]How to Save Contacts in phone using Qr code data in Flutter
I want to save the Contacts numbers in my phone using QR code data in Flutter.我想使用Flutter中的QR码数据将联系人号码保存在手机中。
Using this package for managing user contact book on Android & iOS and this package or any other with qr scanning ability.使用此 package管理 Android 和 iOS 和此 package或任何其他具有二维码扫描功能的用户通讯录。
First create a template for qr information.首先创建一个二维码信息模板。 Flutter contacts lets you save with vCard format which would be very useful, or just have contact name & number raw in qr data. Flutter 联系人可让您以非常有用的 vCard 格式保存,或者仅在 qr 数据中保留联系人姓名和号码。
Once you have consistent formatting of qr data, after user scans code, pass data inside it to a new contact:一旦您拥有一致的二维码数据格式,在用户扫描代码后,将其中的数据传递给新联系人:
final newContact = Contact()
..name.first = 'John' //<- value from qr code
..name.last = 'Smith' //<- value from qr code
..phones = [Phone('555-123-4567')]; //<- value from qr code
await newContact.insert();
More information available in package descriptions. package 描述中提供了更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.