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 display loading progress when loading images from the network #64

Open nlcuong opened 5 months ago

nlcuong commented 5 months ago

Is there a way to show CircularProgressIndicator while the image is loading?

Image(
     image: Svg( url, source: SvgSource.network ),
            width: 32,
            height: 32,
            loadingBuilder: (_, child, loadingProgress) {
              if (loadingProgress == null) {
                return child;
              } else {
                return const Center(
                  child: SizedBox(
                    width: 20,
                    height: 20,
                    child: CircularProgressIndicator(
                      color: Colors.white,
                      strokeWidth: 2,
                    ),
                  ),
                );
              }
            },
);

I tried using loadingBuilder as above but loadingProgress is always non-null.