如何从 flutter 插件 vCard 中获取数据

How to get data out of flutter plugin vCard

所以我正在尝试制作一个 flutter 应用程序来显示从电子名片中提取的联系信息。但是我在如何过滤掉名字、姓氏、phone 号码等数据方面遇到了麻烦。这就是提取的 vcard 数据的样子

I/flutter (11933): BEGIN:VCARD
I/flutter (11933): VERSION:3.0
I/flutter (11933): FN;CHARSET=UTF-8:FirstName MiddleName LastName
I/flutter (11933): N;CHARSET=UTF-8:LastName;FirstName;MiddleName;;
I/flutter (11933): NICKNAME;CHARSET=UTF-8:
I/flutter (11933): BDAY:20201011
I/flutter (11933): TEL;TYPE=WORK,VOICE:Work Phone Number
I/flutter (11933): ORG;CHARSET=UTF-8:ActivSpaces Labs
I/flutter (11933): URL;CHARSET=UTF-8:https://github.com/valerycolong
I/flutter (11933): NOTE;CHARSET=UTF-8:Notes on contact
I/flutter (11933): REV:2020-10-11T15:35:06.168221
I/flutter (11933): END:VCARD

谁能帮我解决这个问题。我试过使用 vcard_parser 插件,它的输出也让我很困惑,因为我是 flutter

的新手
I/flutter (11933): {BEGIN: VCARD, VERSION: 3.0, FN;CHARSET=UTF-8: {name: UTF-8, value: FirstName MiddleName LastName}, N;CHARSET=UTF-8: {name: UTF-8, value: LastName}, NICKNAME;CHARSET=UTF-8: {name: UTF-8, value: }, BDAY: 20201011, TEL;TYPE=WORK,VOICE: {name: WORK,VOICE, value: Work Phone Number}, ORG;CHARSET=UTF-8: {name: UTF-8, value: ActivSpaces Labs}, NOTE;CHARSET=UTF-8: {name: UTF-8, value: Notes on contact}, END: VCARD}

感谢您的帮助!

尝试Simple Vcard Parser 这是从VCard中提取数据的flutter包。

更新你的pubspec.yaml

  dependencies:
  ...
  simple_vcard_parser: ^0.1.3

用法:

import 'package:simple_vcard_parser/simple_vcard_parser.dart';
VCard vc = VCard(myVCard);
print(vc.version); 
print(vc.formattedName); 
print(vc.organisation); 
print(vc.title); 
print(vc.email); 
print(vc.typedTelephone); 
print(vc.name);