OpenFlutter / flutter_share_me

Flutter Plugin for sharing contents to social media. You can use it share to Facebook , WhatsApp , Twitter And System Share UI. Support Url and Text.
https://github.com/lizhuoyuan
Apache License 2.0
160 stars 159 forks source link

WhatsApp sharing is not working #31

Closed ederluca closed 3 years ago

ederluca commented 4 years ago

Good afternoon

I am trying to implement the sharing via whatsapp where I am sending image and text, however when the routine calls whatsapp only the text appears and sending only the text below follows what I am doing.

`File file = File(savePath); var raf = file.openSync(mode: FileMode.write);
raf.writeFromSync(response.data); await raf.close();

  if (file != null) {
    String base64;
    if ((tiposhared == 'W') || (tiposhared == 'WB')) {
      base64 = base64Encode(file.readAsBytesSync());
      if (tiposhared == 'W') {
        FlutterShareMe().shareToWhatsApp(msg: com.eComDesc, base64Image: base64);
      } else {
        FlutterShareMe().shareToWhatsApp4Biz(msg: com.eComDesc, base64Image: base64);
      }
    }
  }`
ibtesam123 commented 4 years ago

you have to append "data:image/jpeg;base64," in front of base64.

 String base64Img = await toBase64Image(myImage);
 base64Img = "data:image/jpeg;base64," + base64Img;