Another flutter_svg.dart error. Unable to load asset
I recommend using websafe_svg instead. It's a lot better and simplier, here is an example of some code.
WebsafeSvg.asset(
'dev_assets/cfg67.svg',
color: Colors.red,
height: 25,
width: 25,
),
Package Link: Websafe SVG Package
marcusaureliusbrutus
Updated on December 21, 2022Comments
-
marcusaureliusbrutus over 1 year
This question has been asked a LOT!!! I have gone through all the recommendations which I will be listing below but still no go. Need help.
======= Problem: SVG files won't load using Flutter package:flutter_svg/flutter_svg.dart.
======= Config Snippet:
final String myimage1str = 'images/splashtest.svg'; final Widget myimage1 = SvgPicture.asset('myimage1str',semanticsLabel: 'Wazzup!!',color: Colors.blue,); @override Widget build(BuildContext context) { return new Scaffold( body: Center( child: Stack( children: [ Container( //child: SvgPicture.asset("images/splashtest.svg",height: 900.0,width: 540.0,allowDrawingOutsideViewBox: true,), child: myimage1 ),
======= Error:
Unable to load asset: myimage1str
When the exception was thrown, this was the stack:
#0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:221:7)======= Tshoot steps already taken:
- Check syntax/position/spacing in pubspec.yaml.
- Images folder is located under root.
- Ran flutter clean.
- Invalidated caches and restarted.