-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 Answers1

0

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,
    ),
    
Canilho
  • 944
  • 5
  • 11