将base64转换为图像|不工作|扑
因此,我想做一个简单的事情,但由于某些原因,它无法正常工作。我从服务器中获得了一个基本64字符串,我需要将其转换为图像。当我将其放在网站中时,例如 base64guru ,它起作用。但是,我无法在Flutter应用程序中做同样的事情。
这是我的代码的样子:
final decodedBytes = base64Decode(base64String);
var file = File("userPdf.png");
file.writeAsBytesSync(decodedBytes);
return Image.file(file);
执行此操作时,我会发现一个错误说明:
filesystemexception:无法打开文件,path ='userpdf.png(OS错误: 仅读取文件系统,errno = 30)
知道我在做什么错以及如何做到这一点?任何帮助将不胜感激。
So, I want to do a simple thing but for some reasons it is not working. I get a base64 string from the server which I need to convert to an image. When I put that retrieved in the websites like base64guru, it works. However I'm unable to do the same in my flutter app.
Here's what my code looks like:
final decodedBytes = base64Decode(base64String);
var file = File("userPdf.png");
file.writeAsBytesSync(decodedBytes);
return Image.file(file);
When this is executed, I get an error stating :
FileSystemException: Cannot open file, path = 'userPdf.png (OS Error:
Read-only file system, errno = 30)
Any idea what I'm doing wrong and how I can do this ?? Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,当我在容器中包装sfpdfviewer.memory(bytes)时,这得到了解决。不过,不确定为什么没有容器就无法正常工作。
整个解决方案:
Well, this got resolved when I wrapped SfPdfViewer.memory(bytes) inside a Container. Though, not sure why it wasn't working without a Container.
The whole solution:
有一个简单的方法
There is a simple way