ankushmishra2903-official / whatsapp_share2

MIT License
3 stars 21 forks source link

Unhandled Exception: PlatformException(Failed to find configured root that contains #6

Closed droidzone closed 2 years ago

droidzone commented 2 years ago
E/flutter (28040): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(Failed to find configured root that contains /data/data/com.droidzone.myopipclinic/cache/prescription.pdf, null, null, null)
E/flutter (28040): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter (28040): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:177:18)
E/flutter (28040): <asynchronous suspension>
E/flutter (28040): #2      WhatsappShare.shareFile (package:whatsapp_share2/whatsapp_share2.dart:78:9)
E/flutter (28040): <asynchronous suspension>
E/flutter (28040): #3      _EMRScreenState.sharePDFDirectly (package:myopipclinic/screens/emr_screen.dart:276:5)
E/flutter (28040): <asynchronous suspension>
E/flutter (28040): 

Getting this exception when trying to share files

  Future sharePDFDirectly() async {
    await hasStoragePermissions();
    String tempdirPath = await getdir();
    var link = await connection.getPrescriptionLink(
      checkinID: checkIn.checkinno,
    );
    print(
        "sharePDFDirectly:: response in getPrescription: $link type:${link.runtimeType}");
    // First send a message to the customer, so that the next step of sharing the pdf goes to the right recipient.

    Dio dio = Dio();
    String fpath = tempdirPath + "/prescription.pdf";
    Response retData = await dio.download(link, fpath);
    print("Downloaded prescription before sharing through Whatsapp to $fpath");
    List<String> filePaths = [];
    filePaths.add(fpath);

    await WhatsappShare.shareFile(
      text: 'Whatsapp share text',
      phone: '91${customer.mobile}',
      filePath: filePaths,
    );
devangichhatbar commented 2 years ago

Please try using the below link.

https://stackoverflow.com/a/56186903/8197867

karebmusu commented 2 years ago

which path should i use? i already tried using getTemporaryDirectory and its still error @devangichhatbar

smit-sk commented 2 years ago

Make sure whatsaap is installed