0
  ======== Exception caught by image resource service 
 ================================================
The following ArgumentError was thrown resolving an image codec:

Invalid argument(s): No host specified in URI file:///assets/Upload/Item/214b5d5c-ca86-45f5- bb45- 7850559a23bb.jpg

When the exception was thrown, this was the stack:

#0 _HttpClient._openUrl (dart:_http/http_impl.dart:2636:9)

#1 _HttpClient.getUrl (dart:_http/http_impl.dart:2565:48)

#2 NetworkImage._loadAsync (package:flutter/src/painting/_network_image_io.dart:89:59)

#3 NetworkImage.load

(package:flutter/src/painting/_network_image_io.dart:50:14)

#4 ImageProvider.resolveStreamForKey.

(package:flutter/src/painting/image_provider.dart:503:13)

...

Image provider: NetworkImage("assets/Upload/Item/214b5d5c-ca86-45f5- 
 bb45-  7850559a23bb.jpg",    scale:  1.0)

Image key: NetworkImage("assets/Upload/Item/214b5d5c-ca86-45f5-bb45-
7850559a23bb.jpg", scale:  1.0)
2
  • Ask yourself: is assets/Upload/Item/214b5d5c-ca86-45f5-bb45-7850559a23bb.jpg a valid URL? Commented Sep 28, 2021 at 14:51
  • suggest me what i do ? Commented Sep 28, 2021 at 14:58

1 Answer 1

1

You are using the wrong image provider class to provide locally stored images. The proper use-case for NetworkImage() class is providing remotely hosted URLs such as hosted in web/storage bucket.

In your case, in order to provide an image locally stored in the assets folder, you need to use AssetImage() instead. Please follow the documentation for more details.

https://api.flutter.dev/flutter/painting/NetworkImage-class.html https://api.flutter.dev/flutter/painting/AssetImage-class.html

Sign up to request clarification or add additional context in comments.

6 Comments

Image is stored in an array then I call the array through network image also another issue is this Exception: Invalid image data
Unless array items are fully qualified remote host URLs such as https://example.com/image NetworkImage provider can not render them. According to provided snippet on your question, you want to render some images from the assets directory of the app. Therefore you need to use AssetImage instead of no matter how you have stored the data.
Unable to load asset: assets/Upload/Item/0d8442aa-a1cc-4716-bb73-7ceee78464fe.jpgWhen the exception was thrown, this was the stack: #0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:224:7) <asynchronous suspension> #1 AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:672:14) <asynchronous suspension> Image provider: AssetImage(bundle: null, name: "assets/Upload/Item/0d8442aa-a1cc-4716-bb73-7ceee78464fe.jpg")
Have you enabled the assets directory in pubspec.yaml? the assets directory should enable by adding the following lines under flutter: in pubspec.yaml. There would be a commented version available describing how to enable this. flutter: # To add assets to your application, add an assets section, like this: assets: - assets/images/
Yes its fine but still same issue
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.