Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use jovial_svg with assets

I was using jovial_svg library for fetching svg from internet because my svg files looks corrupted with flutter_svg library. Now I want to use jovial_svg library for my files which are in my assets folder.

I tried

ScalableImageSource.fromSvg()

but i didn't make it.

like image 397
Hüseyin Sezen Avatar asked Oct 23 '25 16:10

Hüseyin Sezen


1 Answers

You can do like this

ScalableImageWidget.fromSISource(
      si: ScalableImageSource.fromSvg(
        MySVG(imagePath: image.svg),
        'key',
        compact: true,
      ),
    ),

class MySVG extends AssetBundle {
  final String imagePath;
  MySVG({required this.imagePath});
  @override
  Future<ByteData> load(String key) async {
    // TODO: implement load
    return await rootBundle.load(imagePath);
  }

  @override
  Future<T> loadStructuredData<T>(
      String key, Future<T> Function(String value) parser) {
    // TODO: implement loadStructuredData
    throw UnimplementedError();
  }
}
like image 62
Ankit Parmar Avatar answered Oct 26 '25 07:10

Ankit Parmar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!