flutter_svg icon indicating copy to clipboard operation
flutter_svg copied to clipboard

Unable to load assets is not fixed

Open Ankit0080 opened this issue 3 years ago • 5 comments

This is my Pubspec.yaml file

version: 1.0.0+1

environment: sdk: ">=2.7.0 <3.0.0"

dependencies: flutter: sdk: flutter fluttertoast: ^3.1.3 page_transition: "^1.1.7+2"

The following adds the Cupertino Icons font to your application.

Use with the CupertinoIcons class for iOS style icons.

cupertino_icons: ^1.0.0 json_annotation: ^3.1.1 shared_preferences: ^2.0.5 flutter_svg: ^0.22.0

dev_dependencies: build_runner: ^1.11.5 json_serializable: ^3.5.1 flutter_test: sdk: flutter http: any

For information on the generic Dart part of this file, see the

following page: https://dart.dev/tools/pub/pubspec

The following section is specific to Flutter.

flutter:

The following line ensures that the Material Icons font is

included with your application, so that you can use the icons in

the material Icons class.

uses-material-design: true

assets: - assets/

An image asset can refer to one or more resolution-specific "variants", see

https://flutter.dev/assets-and-images/#resolution-aware.

For details regarding adding assets from package dependencies, see

https://flutter.dev/assets-and-images/#from-packages

To add custom fonts to your application, add a fonts section here,

in this "flutter" section. Each entry in this list should have a

"family" key with the font family name, and a "fonts" key with a

list giving the asset and other descriptors for the font. For

example:

fonts: - family: NotoSansMedium fonts: - asset: assets/fonts/NotoSans-Medium.ttf - family: NotoSansBold fonts: - asset: assets/fonts/NotoSans-Bold.ttf - family: NotoSansRegular fonts: - asset: assets/fonts/NotoSans-Regular.ttf - family: NotoSansItalic fonts: - asset: assets/fonts/NotoSans-Italic.ttf

\

This is my svg loading code

Row( children: <Widget>[ SvgPicture.asset("assets/calendar.svg") ], )

Expected behaviour : Should work

Result : Unable to load asets throwing exception i have put image name and the image is stored in asstest folder

Ankit0080 avatar Jul 29 '21 09:07 Ankit0080

Pretty sure this is unrelated to this package.

It is odd though, because it I have it working. I have cupertino_icons and uses-material-design: true, svg assets, png assets and fonts setup in pubspec.yaml. I do have stop the app after adding an asset, then run flutter pub get and then start it again. Flutter pub get and then restart does not work for me with the Unable to load assets exception being thrown. But that is not related to svg assets alone. The same is true for the png assets.

Also make sure you have the indentation correct in the pubspec.yaml. It is stupidly sensitive to indentation.

marcov-dart avatar Jul 30 '21 04:07 marcov-dart

I have the same issue, and i used in parallel flutter image.asset widget which loaded the assets files, but the svgPicture.asset unable to load asset

AndrejBykov avatar Aug 16 '21 12:08 AndrejBykov

This is shame because what for then this package benn created if it doesn't provide what expected

AndrejBykov avatar Aug 16 '21 12:08 AndrejBykov

"Unable to load assets" everytime this package throw this exception.

Ankit0080 avatar Sep 29 '21 08:09 Ankit0080

I'd need a full reproduction of this. This is likely an issue with the way the pubspec is set up in the project rather than this package.

dnfield avatar Sep 29 '21 17:09 dnfield