Ariel B
Ariel B

Reputation: 1

Flutter Unable to load asset: but dir doesnt exist

flutter throws these errors but the images he cant find does not exist! the images that do exist are in the folder assets/images/ and have other (normal) names. i imported them properly in pubspec.yaml what can be the solution for this weird problem?

══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
The following assertion was thrown resolving an image codec:
Unable to load asset: assets/images/v.png

When the exception was thrown, this was the stack:
#0      PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:223:7)
<asynchronous suspension>
#1      AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:669:31)
#2      AssetBundleImageProvider.load (package:flutter/src/painting/image_provider.dart:652:14)
#3      ImageProvider.resolveStreamForKey.<anonymous closure> (package:flutter/src/painting/image_provider.dart:505:13)
#4      ImageCache.putIfAbsent (package:flutter/src/painting/image_cache.dart:360:22)
#5      ImageProvider.resolveStreamForKey (package:flutter/src/painting/image_provider.dart:503:80)
#6      ScrollAwareImageProvider.resolveStreamForKey (package:flutter/src/widgets/scroll_aware_image_provider.dart:108:19)
#7      ImageProvider.resolve.<anonymous closure> (package:flutter/src/painting/image_provider.dart:334:9)
#8      ImageProvider._createErrorHandlerAndKey.<anonymous closure>.<anonymous closure> (package:flutter/src/painting/image_provider.dart:464:26)
(elided 13 frames from dart:async)

Image provider: AssetImage(bundle: null, name: "assets/images/v.png")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#8dc86(), name: "assets/images/v.png",
  scale: 1.0)
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by image resource service ════════════════════════════════════════════════
The following assertion was thrown resolving an image codec:
Unable to load asset: assets/images/v.png

When the exception was thrown, this was the stack: 
#0      PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:223:7)
<asynchronous suspension>
#1      AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:669:31)
#2      AssetBundleImageProvider.load (package:flutter/src/painting/image_provider.dart:652:14)
#3      ImageProvider.resolveStreamForKey.<anonymous closure> (package:flutter/src/painting/image_provider.dart:505:13)
...
Image provider: AssetImage(bundle: null, name: "assets/images/v.png")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#8dc86(), name: "assets/images/v.png", scale: 1.0)
════════════════════════════════════════════════════════════════════════════════════════════════════

Another exception was thrown: Unable to load asset: assets/images/e.png

════════ Exception caught by image resource service ════════════════════════════════════════════════
Unable to load asset: assets/images/e.png
════════════════════════════════════════════════════════════════════════════════════════════════════

Another exception was thrown: Unable to load asset: assets/images/h.png

════════ Exception caught by image resource service ════════════════════════════════════════════════
Unable to load asset: assets/images/h.png
════════════════════════════════════════════════════════════════════════════════════════════════════

Another exception was thrown: Unable to load asset: assets/images/i.png

════════ Exception caught by image resource service ════════════════════════════════════════════════
Unable to load asset: assets/images/i.png
════════════════════════════════════════════════════════════════════════════════════════════════════

Upvotes: 0

Views: 653

Answers (1)

Johny Saini
Johny Saini

Reputation: 909

 you can go to pubspec.yaml and give folder path there
 assets:
- assets/images/

Don't need to give the name of image just give folder path then

run app again

Upvotes: 1

Related Questions