渲染时 Flutter SVG 延迟

use*_*517 7 svg rendering flutter

我在行中显示 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,
              ),
            ]),
          ),
        ],
      ),
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

Thi*_*ira 13

更新:

  await precachePicture(
    ExactAssetPicture(SvgPicture.svgStringDecoderBuilder, 'assets/my_icon.svg'),
    null,
  );
Run Code Online (Sandbox Code Playgroud)

您可以使用 PreCachePicture,它对我有用:

Future.wait([
  precachePicture(
    ExactAssetPicture(SvgPicture.svgStringDecoder, 'assets/my_icon.svg'),
    null,
  ),
  precachePicture(
    ExactAssetPicture(SvgPicture.svgStringDecoder, 'assets/my_asset.svg'),
    null,
  ),
]);
Run Code Online (Sandbox Code Playgroud)

您需要在上一个屏幕小部件中执行此操作,例如在main