简体   繁体   中英

Another flutter_svg.dart error. Unable to load asset

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.

在此处输入图像描述

  1. Images folder is located under root.

在此处输入图像描述

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM