gpt4 book ai didi

flutter - 如何在Flutter中将图像转换为Base64

转载 作者:行者123 更新时间:2023-12-03 04:23:08 33 4
gpt4 key购买 nike

我正在尝试将图像转换为base64,但结果无法作为图像查看。

下面是我的代码。

File image = File(path);
final bytes = image.readAsBytesSync();
print(base64Encode(bytes));

结果:
/9j/4Q+WRXhpZgAATU0AKgAAAAgACgEPAAIAAAAFAAAAhgEQAAIAAAAKAAAAjAEaAAUAAAABAAAAlgEbAAUAAAABAAAAngEoAAMAAAABAAIAAAExAAIAAABAAAAApgEyAAIAAAAUAAAA5gITAAMAAAABAAEAAIdpAAQAAAABAAAA+oglAAQAAAABAAAC3gAAAvh2aXZvAAB2aXZvIDE3MjMAAAAASAAAAAEAAABIAAAAAW1zbTg5NTNfNjQtdXNlciA5IFBLUTEuMTkwMTE4LjAwMSBjb21waWxlcjA0MDEyMDI1IHJlbGVhc2Uta2V5cwAyMDIwOjA0OjIzIDE1OjM3OjMyAAAcgpoABQAAAAEAAAJQgp0ABQAAAAEAAAJYiCIAAwAAAAEAAAAAiCcAAwAAAAEClgAAkAAABwAAAAQwMjIwkAMAAgAAABQAAAJgkAQAAgAAABQAAAJ0kQEABwAAAAQBAgMAkgEACgAAAAEAAAKIkgIABQAAAAEAAAKQkgMACgAAAAEAAAKYkgcAAwAAAAEAAQAAkgkAAwAAAAEAAAAAkgoABQAAAAEAAAKgkpAAAgAAAAcAAAKokpEAAgAAAAcAAAKwkpIAAgAAAAcAAAK4oAAABwAAAAQwMTAwoAEAAwAAAAEAAQAAoAIABAAAAAEAAAHgoAMABAAAAAEAAAKAoAUABAAAAAEAAAK/ohcAAwAAAAEAAgAAowEABwAAAAEBAAAApAIAAwAAAAEAAAAApAMAAwAAAAEAAAAApAUAAwAAAAEAHQAApAYAAwAAAAEAAAAAAAAAAAAAAAoAAAD6AAAAyAAAAGQyMDIwOjA0OjIzIDE1OjM3OjMyADIwMjA6MDQ6MjMgMTU6Mzc6MzIAAAASIwAAA+gAAADIAAAAZAAAAAAAAABkAAABfgAAAGQ0OTc4OTYAADQ5Nzg5NgA6NDk3ODk2AAACAAEAAgAAAARSOTgAAAIABwAAAAQwMTAwAAAAAAAAAQAFAAUAAAABAAAC8AAAAAAAAAD

但是以上结果不能作为图像查看。
我用这些网站检查
codebeautify.org

base64decode

这个问题有解决方案吗?

最佳答案

Print函数不会打印所有内容
如果您需要复制此长字符串,则可以设置断点并在Variables中查看
您可以在下面看到图片

enter image description here

关于flutter - 如何在Flutter中将图像转换为Base64,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61383061/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com