Another flutter_svg.dart error. Unable to load asset

2,886

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

Share:
2,886
marcusaureliusbrutus
Author by

marcusaureliusbrutus

Updated on December 21, 2022

Comments

  • marcusaureliusbrutus
    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:

    1. Check syntax/position/spacing in pubspec.yaml.

    enter image description here

    1. Images folder is located under root.

    enter image description here

    1. Ran flutter clean.
    2. Invalidated caches and restarted.