Dhruv Dudeja
Dhruv Dudeja

Reputation: 13

How to get data out of flutter plugin vCard

So I'm trying to make an flutter app will display contact information extracted from vcards. But I'm having trouble with how to filter out the data like first name, last name, phone number etc. This is how extracted vcard data looks like

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

Can anyone help me with this. I've tried using vcard_parser plugin and its output is also very confusing to me as I'm new in 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}

Thanks for the help!

Upvotes: 0

Views: 1619

Answers (1)

Kerim Amanov
Kerim Amanov

Reputation: 242

Try Simple Vcard Parser. This is flutter package for extracting data from VCard.

Update your pubspec.yaml

  dependencies:
  ...
  simple_vcard_parser: ^0.1.3

Usage:

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);

Upvotes: 1

Related Questions