Flutter 在颤振中,如何检测复制文件的完成?
我是颤振的初学者 我想做这个过程Flutter 在颤振中,如何检测复制文件的完成?,flutter,Flutter,我是颤振的初学者 我想做这个过程 1. save a image file. 2. read the property information of the saved image file. 下面是它的代码 // save a image file. String mainDir = await getMainDirectory(widget.topic); String path = mainDir + '/' + count.toString(); image.copy(path);
1. save a image file.
2. read the property information of the saved image file.
下面是它的代码
// save a image file.
String mainDir = await getMainDirectory(widget.topic);
String path = mainDir + '/' + count.toString();
image.copy(path);
ImageProperties properties;
try {
// get the property information of the image file.
properties = await FlutterNativeImage.getImageProperties( path);
}
on PlatformException catch(e) {
print( e );
// try again ...
properties = await FlutterNativeImage.getImageProperties(
path);
}
当此代码运行时,有时会发生错误。
错误消息为“文件不存在”
因此,我必须再次调用“getImageProperties()”函数,然后才能获得该属性
如果我能检测到文件拷贝的完成,我就能使这些代码变得更好
有什么建议吗 您可以使用wait确保图像复制完成
final File newImage = await image.copy(path);
它可以与wait关键字配合使用。非常感谢你!很乐意帮忙。如果这对您有帮助,请将其标记为答案。谢谢