skip to Main Content

I’m having trouble adding assets to my Flutter app. If I add my assets folder (myAssets) like below in pubspec.yaml everything is fine on the first run and debug.

flutter:
  uses-material-design: true
  assets:
    - myAssets/

On the second run and debug, it will give me a build process failed exception.

When I run the app from Windows command prompt I get the error:

‘flutterProjectsmeanartist2meanartistmyAssetscyborgrobot.jpeg’
(OS Error: Cannot create a file when that file already exists.

Am I missing something fundamental? Should I delete the build folder manually after every run, or am I missing code to clean up at the program end? I’m fairly new to Flutter, as you may have guessed 🙂

Deleting the build folder after every run fixes the issue, but I don’t understand why or if this is expected behaviour.

2

Answers


  1. Chosen as BEST ANSWER

    If anyone is struggling with the same issue I managed to resolve this by reinstalling vs code and deleting the flutter sdk. I also went all out and removed all trace of the flutter and dart extensions form vscode. Everything is now working normally.


  2. There doesn’t seem to be any problems with your pubspec.yaml file and it’s not normal for a Flutter project to require the build folder to be deleted after every run.

    The only thing that I am finding strange is that you are using a backslash instead of a forward slash for your image path.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search