【发布时间】:2021-03-27 05:21:27
【问题描述】:
Hello and thank you in advance!
我正在处理图像编辑。我可以从图像选择器中选择图像并在 drawstringdrawstring 的帮助下重写它。我可以将图像保存在我的文档目录中。我想通过 Share 插件从 documentDirectory 路径分享我的图像。但是,我遇到了一个错误。
代码和错误详情如下所示。
代码:
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)] 未处理异常:无法加载资产:/data/user/0/com.photogranth.watermark/app_flutter
【问题讨论】:
标签: flutter share file-sharing