我将图像显示为 SVG 文件和文本。
出于某种原因,svg 图像的渲染速度比屏幕的其余部分慢,从而导致延迟,这对用户体验不利。
这种延迟正常吗?我该怎么做才能让整个屏幕同时呈现?
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
'lib/assets/muslim_coloc_logo.svg',
height: 40.0,
width: 40.0,
),
SizedBox(width: 2.0,),
RichText(
text: TextSpan(children: [
TextSpan(
text: 'uslim',
style: MC_titleWhite,
),
TextSpan(
text: 'Coloc',
style: MC_titleWhite50,
),
]),
),
],
),
最佳答案
您可以使用 PreCachePicture,它对我有用:
Future.wait([
precachePicture(
ExactAssetPicture(SvgPicture.svgStringDecoder, 'assets/my_icon.svg'),
null,
),
precachePicture(
ExactAssetPicture(SvgPicture.svgStringDecoder, 'assets/my_asset.svg'),
null,
),
]);
您需要在之前的屏幕小部件中执行此操作,例如在您的 中主 ,例如
关于渲染时抖动 SVG 延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66872111/