Search code examples
androidiosflutterqr-code

How to generate QR code which can be used to save contact in flutter


I'm trying to generate a QR code which contains contact information about people and they can share the QR code. The person when scans the QR code it should ask the person to save the contact.

Currently I'm using library qr_flutter But it only shows text and it's not able to create a contact qr code


Solution

  • this is a small example how you can show a contact card with the qr_flutter package.

    final vcardData = 'BEGIN:VCARD\n'
      'VERSION:3.0\n'
      'N:Doe;John;;Mr.;\n'
      'TEL;TYPE=CELL:+33 0600000000\n'
      'EMAIL:john.doe@example.com\n'
      'END:VCARD';
    
    QrImage(
      data: vcardData,
      version: QrVersions.auto,
      size: 300.0,
      backgroundColor: Colors.white,
      foregroundColor: Colors.black,
      padding: const EdgeInsets.all(25.0),
    )
    
    

    for this example I use qr_flutter:4.0.0