Flutter 如何共享 directory.path 图像

问题描述

您好,提前谢谢您

我从事图像编辑工作,我可以从图像选择器中选择图像并在拉绳的帮助下对其进行重写 所以我可以将图像保存在我的文档目录中 所以我需要的是!我想从 documentDirectory PATH THROWH SHARE PLUG IN 分享我的图像 代码错误详情如下所示。

代码

FlatButton(
      child: Text("Apply Watermark Over Image"),onpressed: () async {
        final image1 = ui.decodeImage(_originalImage.readAsBytesSync());

        ui.drawString(image1,ui.arial_24,300,400,'Hello And thank you');


        final documentDirectory = await getApplicationDocumentsDirectory();

        final file = new File(p.join(documentDirectory.path,"merged_image.jpg"));
       
        file.writeAsBytesSync(ui.encodeJpg(image1));
          // I HAVE THE IMAGE IN - documentDirectory.path "HERE I CANT SHARE THAT IMAGE" 
        final ByteData bytes = await rootBundle.load(documentDirectory.path);
        await Share.file('esys image','esys.png',bytes.buffer.asUint8List(),'image/png',text: 'My optional text.');
      },)

我收到此错误

[ERROR:Flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Unable to load asset: /data/user/0/com.photogranth.watermark/app_Flutter

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)