androidiosfluttermobile

How to get information in my qr code and display it in add new contact automatically


I am developing a Flutter mobile app for business cards and I have an issue. After scanning a QR code in my application, how can I get the information from the QR code and display it in the 'Add New Contact' automatically on the scanner phone? i work with qr_flutter package

   string qrdata=   {   "fname": 'AOUICHE Redouane',"adr":'vdsv', "phone":'00000',   "job":'IT admin specialiste',  
"email":'r.aouiche@exwor.net',   }   ''';

 Align(
          child: Center(
            child: SingleChildScrollView(
              child: Column(
                children: [
                  QrImageView(
                    data: qrData.toString(),
                    size: 200,
                    backgroundColor: Colors.white,
                    version: QrVersions.auto,
                  ),
                ],
              ),
            ),
          ),
        ),

Solution

  • QR codes used for contact sharing often follow the vCard :

    example of vCard :

    BEGIN:VCARD
    VERSION:3.0
    FN:John Doe
    TEL:+1234567890
    EMAIL:johndoe@example.com
    END:VCARD
    

    Code :

    String qrdata = '''
    BEGIN:VCARD
    VERSION:3.0
    FN:AOUICHE Redouane
    TEL:+1200000
    EMAIL:r.aouiche@exwor.net
    END:VCARD
    ''';
    
    
    
    return Align(
              child: Center(
                child: SingleChildScrollView(
                  child: Column(
                    children: [
                      QrImageView(
                        data: qrData.toString(),
                        size: 200,
                        backgroundColor: Colors.white,
                        version: QrVersions.auto,
                      ),
                    ],
                  ),
                ),
              ),
            ),
    

    You just need to implement this code for QR scanning, and it will automatically display the option to add the contact.