flutterdart

How to solve PathExistsException error in flutter?


When I run my flutter app I get an error:

Target debug_android_application failed: PathExistsException: Cannot copy file to 'path of png', path = 'C:\Users\User\Desktop\flutter_projects\quiz_app\assets\images\quizlogo.png' (OS Error: Cannot create a file when that file already exists., errno = 183)

When I write flutter clean and then flutter pub get in the terminal and restart VS Code I can run my app for one time but after this one time the error appears again.

code of pubspec.yaml where I declare assets if it helps:

assets:
  - assets/images/

How can I fix this?


Solution

  • I have solved it by moving the assets folder from lib folder to the root of the project.