Flutter assets error: EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE

前端 未结 9 1786
借酒劲吻你
借酒劲吻你 2021-01-05 09:17

flutter can not find my images assets, what can I be doing wrong?

I got the error on debugger:

Launching lib/main.dart on XT1097 in debug mode... Built build

9条回答
  •  耶瑟儿~
    2021-01-05 09:46

    This is how this resolved for me.

    Previously I was using the exact paths to images as suggested

     assets:
     - assets/logo_linked_in.jpg
     - assets/logo_medium.png
     - assets/logo_stackoverflow.png
     - assets/myself.jpg
     - assets/sparta.jpg
     - assets/fox.png
    

    Then I tried just the parent directory name, which was just using:

    assets:
     - assets/
    

    Voila! It worked like a charm!

    I hope this helps someone.

    P.S. - For newbies like me:

    Make sure you have correctly indented the pubspec.yaml as this is very important for the build.

提交回复
热议问题