Home > Blockchain >  please suggest how svg images shows
please suggest how svg images shows

Time:02-17

════════ Exception caught by SVG ═══════════════════════════════════════════════
    The following assertion was thrown resolving a single-frame picture stream:
    Unable to load asset: assets/images/Brochur.svg
    
    When the exception was thrown, this was the stack
    #0      PlatformAssetBundle.load
    package:flutter/…/services/asset_bundle.dart:224
    <asynchronous suspension>
    #1      AssetBundle.loadString
    package:flutter/…/services/asset_bundle.dart:68
    <asynchronous suspension>
    #2      AssetBundlePictureProvider._loadAsync
    package:flutter_svg/src/picture_provider.dart:546
    <asynchronous suspension>
    Picture provider: ExactAssetPicture(name: "assets/images/Brochur.svg", bundle: null, colorFilter: null)
    Picture key: AssetBundlePictureKey(bundle: PlatformAssetBundle#cfadd(), name: "assets/images/Brochur.svg", colorFilter: null, theme: SvgTheme(currentColor: null, fontSize: 14.0, xHeight: 7.0))
    ════════════════════════════════════════════════════════════════════════════════
    V/PhoneWindow( 6803): DecorView setVisiblity: visibility = 4, Parent = android.view.ViewRootImpl@2ca2255, this = DecorView@944b46a[MainActivity]
    I/GED     ( 6803): ged_boost_gpu_freq, level 100, eOrigin 2, final_idx 42, oppidx_max 42, oppidx_min 0

Dependency:

 "flutter_svg: ^1.0.3"

code

    GridView.count(
        crossAxisSpacing: 1,
        mainAxisSpacing: 2,
        crossAxisCount: 2,
        children: <Widget>[
          Card(
            child: Stack(
              children: [
                Center(
                  child: SvgPicture.asset("assets/images/Brochur.svg"),
                )
              ],
            ),
          )
        ],
      )

CodePudding user response:

Make sure the following are true:

  1. The file is located at assets/images/Brochur.svg. With assets being in the root directory of your project.
  2. Inside your pubspec.yaml file you have the following
flutter:

  assets:  
    - assets/images/Brochur.svg
  1. You've rebuilt your project since you added the svg to the pubspec.yaml file

CodePudding user response:

There can be a few reasons the issue may have been caused:

  1. Did you add the asset/package while your app was running? If so, you must:
  • Terminate the app.
  • Run flutter pub get
  • Run the app
  1. You may have miswritten the path either in Image.asset or in pubspec.yaml. Can you share the image path or folder structure pic?
  • Related