flutterdartqr-codevcf-vcard

How to add photo/logo in Flutter Vcard


I am designing a new Digital vcard, Name, phone, address etc. it generate Qrcode when we scan that all the details is import to mobile phone device but i am not able to upload photo/ logo. how can I merge uploaded photo to vCard. Please guide and suggest I am new to Flutter.

I want to generate QRcode with vcard details. everything is working fine but facing issues to import uploaded image, when I scan QRcode all the details are directly import to contact with help of Vcard plugin. but I failed to import image from QR code via vcard.

Thank you


Solution

  • To share the generated qr code. Add path_provider, screenshot packages

    //Define a controller for screenshot

    ScreenshotController controller = ScreenshotController();
    

    //Wrap your QrImageView with Screenshot

    Screenshot(
                controller: controller,
                child: QrImageView(
                  data: data,
                  foregroundColor: foregroundColor,
                  backgroundColor: backgroundColor,
                  padding: EdgeInsets.all(padding),
                  embeddedImage: image,
                  eyeStyle: QrEyeStyle(
                    eyeShape: eyeShape,
                    color: foregroundColor,
                  ),
                  dataModuleStyle: QrDataModuleStyle(
                    dataModuleShape: dataModuleShape,
                    color: foregroundColor,
                  ),
                ),
              ),
    

    //Now on click of a button

     IconButton(
              onPressed: () async {
                final list = await controller.capture();
                //controller.capture() will capture the widgets wrapped inside Screenshot()
                if (list != null) {
                  final directory = (await getTemporaryDirectory()).path;
                  File imgFile = File(
                      '$directory/${DateTime.now().millisecondsSinceEpoch}.png');
                  imgFile.writeAsBytesSync(list);
    
                  // ignore: deprecated_member_use
                  await Share.shareFiles(
                    [imgFile.path],
                    text: 'hi this is the text',
                  ).catchError((e) {
                    debugPrint('Error: $e');
                  });
                }
              },
              icon: const Icon(Icons.send))
    

    //working in android but in ios only text or image can be share at one time