yang-f / flutter_svg_provider

Use svg as image provider.
https://pub.dev/packages/flutter_svg_provider
Apache License 2.0
47 stars 72 forks source link

How to preload #28

Open marcoberetta96 opened 2 years ago

marcoberetta96 commented 2 years ago

How to preload a SVG showed as following?

Container(
  child: DecoratedBox(
    decoration: BoxDecoration(
      image: DecorationImage(
        repeat: ImageRepeat.repeat,
        image: svg_provider.Svg(
          "assets/test.png",
          size: Size(200, 200),
        ),
        colorFilter: ColorFilter.mode(
          Colors.black12,
          BlendMode.srcIn,
        ),
      ),
    ),
    child: Container(),
  ),
),

I tried with this one but it does not preload the SVG.

precachePicture(
  ExactAssetPicture(SvgPicture.svgStringDecoderBuilder, "assets/test.png"),
  null,
);

After the SVG is showed once, then it's always fast to show up.

pbouttier commented 1 year ago

@marcoberetta96 did you find a solution ? I have the same problem

marcoberetta96 commented 1 year ago

@pbouttier no solution

rocboronat commented 1 year ago

+1 to this issue 😞