Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 什么';资产评估和精确资产评估的区别是什么?_Flutter - Fatal编程技术网

Flutter 什么';资产评估和精确资产评估的区别是什么?

Flutter 什么';资产评估和精确资产评估的区别是什么?,flutter,Flutter,我无法理解AssetImage和ExactAssetImage之间的区别。我可以用 Image( image: AssetImage(chocolateImage), ) 或 没有性能或内存差异。ExactAssetTime唯一的优势是scale属性,但这就是它的全部优势吗?如果是,那么需要什么AssetImage?AssetImage AssetImage从AssetBundle获取图像,然后使用上下文确定要使用的确切图像。然后根据设备像素比率和大小确定图像的最佳配置,然后将其传递给解析

我无法理解
AssetImage
ExactAssetImage
之间的区别。我可以用

Image(
  image: AssetImage(chocolateImage),
)


没有性能或内存差异。
ExactAssetTime
唯一的优势是
scale
属性,但这就是它的全部优势吗?如果是,那么需要什么
AssetImage

AssetImage
AssetImage
AssetBundle
获取图像,然后使用上下文确定要使用的确切图像。然后根据设备像素比率和大小确定图像的最佳配置,然后将其传递给
解析

ExactAssetTime
ExactAssetImage
以类似的方式获取图像,同时将比例与图像关联
ExactAssetImage
忽略传递到解析的配置中的设备像素比率和大小

总之

AssetImage
具有分辨率意识,可以根据正确的设备像素比率和大小选择正确的图像,而
ExactAssetImage
则没有。因此,为了更直接地回答您的问题,ExactAssetImage可以让您更好地控制内存使用,因为它将使用图像的精确分辨率。

这与您在资产列表中提供的具有不同像素密度的图像有关

我的意思是当你提供了这样的图片:

icons/heart.png 
icons/1.5x/heart.png 
icons/2.0x/heart.png
如果使用
AssetImage
,flatter将根据设备密度像素在3个图像之间进行选择

在设备像素比为1.0的设备上,选择的图像将是 heart.png;在设备像素比为1.3的设备上,选择的图像 将是1.5x/heart.png


如果使用
ExactAssetTime
,则可以手动选择比例,执行以下操作:

Image(image: ExactAssetImage("your-asset",scale: 2)),
Image(image: ExactAssetImage("your-asset",scale: 2)),