【发布时间】:2021-08-05 00:07:19
【问题描述】:
这是图像对象:
PickedFile imageFile = await ImagePicker().getImage(source: ImageSource.gallery,maxWidth: 1000,imageQuality: 100);
Image rrimage = Image(image: ResizeImage(FileImage(File(imageFile.path)),height: 224,width: 224));
我想将 Image 对象 (rrimage) 转换为 File 对象。该怎么做?
【问题讨论】:
-
这能回答你的问题吗? How to convert Image to File in Flutter?
-
@AlexHartford 在这个问题中不,图像是一种资产。就我而言,它不是资产。请检查我编辑的代码。
-
为什么不使用
image包:pub.dev/packages/image 头版上的示例似乎是您想要做的:读取文件,调整大小,将其作为文件存储回来。跨度> -
@RichardHeap 是的,我确实尝试过使用该方法。但是由于某种原因,copyResize 函数会降低图像的质量。 ResizeImage 类可以完美地调整大小。并且这个 ResizeImage 对象不能被强制转换为这个图像包的 Image 类。只能转换为原生 Image 小部件类的 Image 类。