-1

======== Exception caught by image resource service ================================================ The following assertion was thrown resolving an image codec: Unable to load asset: "dice-six-faces-one.png".

Exception: Asset not found When the exception was thrown, this was the stack: #0 PlatformAssetBundle.loadBuffer (package:flutter/src/services/asset_bundle.dart:369:7)

Run Asset image in output

1 Answer 1

1

To be able to use local images on your Flutter project you need this:

  • Create a folder assets in your project directory.
    The path for the assets folder should be <my_project_name>/assets

  • Add the images to the created folder.

  • Add the image reference to the configuration file pubspec.yalm

    assets: - assets/myImage.png 
  • How to call the image on your dart code:

    Image( image: AssetImage('assets/myImage.png'), fit: BoxFit.contain, ), 
Sign up to request clarification or add additional context in comments.

1 Comment

this is the only simple correct way in the whole internet.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.