-1

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

Nihar
  • 15
  • 6
  • Have you tried this? https://pub.dev/packages/vcard_maintained – Aks Feb 27 '23 at 07:22
  • @Aks yes I tried and currently I am using this vCard_maintained plugins Only, but it showing Errors like this : The following FileSystemException was thrown resolving an image codec: Cannot open file, path = '' (OS Error: No such file or directory, errno = 2) – Nihar Feb 27 '23 at 12:48
  • I guess you are using picked image path as vcard.photo. Try to convert that image in bytes then store in vcard.photo and when you try to get data from vcard > create image from those bytes. – Aks Feb 28 '23 at 04:27
  • @Aks,okay I will check. one more help, I want to share generated QrCode as a image I added share_plus plugins and its working but it only sharing vCard text field like Name, phone, email etc.. not Qrcode image? what's the issue I am not getting – Nihar Feb 28 '23 at 09:24
  • I am using a package screenshot: ^1.3.0 to take a screenshot and then I am able to send this image using share_plus plugin. But there's a problem in ios devices. I can only send image or text at one time using share_plus plugin. Working fine in Android devices. Here's is the link for code imgur.com/a/aC5q1sb – Aks Feb 28 '23 at 10:19
  • @Aks I'm facing issues and errors, If you have any Example code file please share the link. – Nihar Mar 01 '23 at 06:06
  • you need example code for vcard or creating qr code and share? – Aks Mar 01 '23 at 06:18
  • @Aks I need qrcode and share, actually I created Vcard now it is working fine it generating qrcode. but I'm facing issues during share it sharing qr code backend data like name: , phone: , email: , etc but I want to share generated Qrcode as a Qr image. – Nihar Mar 01 '23 at 06:45
  • Checkout the answer and update the title of your question :) – Aks Mar 01 '23 at 08:50
  • @Aks I got output, It's Working thank you so much. – Nihar Mar 01 '23 at 11:10
  • @Aks I am not able to understand this error. how to solve please help Errors : The following FileSystemException was thrown resolving an image codec: Cannot open file, path = '' (OS Error: No such file or directory, errno = 2) – Nihar Mar 02 '23 at 12:44
  • What are you trying to do with the image? Please elaborate. – Aks Mar 02 '23 at 12:52
  • @Aks Hi, if possible can you please share me the Example code for To fetch the data From Api by get by id method. we user create Vcard the data will store in DB and id is also generated for every entries. the data I need to fetch and display in next page. I'm not able to fetch data. Thank you – Nihar Mar 06 '23 at 12:53
  • Which database are you using? – Aks Mar 06 '23 at 13:19
  • @Aks postgres database – Nihar Mar 08 '23 at 05:35
  • It'll be good if raise another question regarding your problem while using postgres databbase. – Aks Mar 08 '23 at 14:01
  • @Aks I raised question, Please check – Nihar Mar 10 '23 at 06:41

1 Answers1

0

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

Aks
  • 405
  • 4
  • 6