How do I convert an image to base64 and base64 to image? The way I do it doesn't work

拈花ヽ惹草 提交于 2019-12-01 23:43:14

Nah, you're passing the content of the image to create a new file with the content as raw path, this cannot work.

new File.fromRawPath does, according to the docs:

Creates a File object from a raw path, that is, a sequence of bytes as represented by the OS.

What you want to do is to create a file and store the content to that file, this can be done like that (Source):

var imageFile = File('myimage.jpg');
var sink = imageFile.openWrite();
sink.write(bytes);
await sink.flush();
await sink.close();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!