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
?AssetImageAssetImage
从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)),