How to clear Flutter's Build cache?

后端 未结 8 1794
耶瑟儿~
耶瑟儿~ 2020-12-09 07:50

There seems to be a problem with flutter\'s build.

I always need to perform RUN > Flutter Full Restart everytime I run the app to a

相关标签:
8条回答
  • 2020-12-09 08:04

    I found a way to automate running the clean before you debug your code. (Warning, this runs everytime you hit the button, even for hot restart)

    1. First, find the Run > Edit Configurations Menu

    2. Click the External tool '+' icon under Before launch: External tool, Activate tool window.

    3. Run External Tool
    4. Configure it like so. Put the working directory as a directory in your project.

    0 讨论(0)
  • 2020-12-09 08:05

    Same issue with mine.

    New to Flutter. I'm using VS build-in terminal to do flutter run, to run the app in iPhone. It gives me error Error when reading 'lib/student_model.dart': No such file..., which is an old code version in my code. I have changed it to lib/model/student_model.dart.

    And I search this line 'lib/student_model.dart'in the project, it appears filekernel_snapshot.d` containing it. So, it build the project with old code version.

    For me, Flutter clean is not working. Restart VS fix the issue, not sure the problem is due to Flutter or VS?

    And I'm wondering if there is some command to just build flutter project without run?

    0 讨论(0)
  • 2020-12-09 08:07

    Build cache is generated on application run time when a temporary file automatically generated in dart-tools folder, android folder and iOS folder. Clear command will delete the build tools and dart directories in flutter project so when we re-compile the project it will start from beginning. This command is mostly used when our project is showing debug error or running related error. In this answer we would Clear Build Cache in Flutter Android iOS App and Rebuild Project structure again.

    1. Open your flutter project folder in Command Prompt or Terminal. and type flutter clean command and press enter.

    2. After executing flutter clean command we would see that it will delete the dart-tools folder, android folder and iOS folder in our application with debug file. This might take some time depending upon your system speed to clean the project.

    For more info, see https://flutter-examples.com/clear-build-cache-in-flutter-app/

    0 讨论(0)
  • 2020-12-09 08:10

    If in android studio Tools->Flutter->Clean

    0 讨论(0)
  • 2020-12-09 08:13

    I tried flutter clean and that didn't work for me. Then I went to wipe the emulator's data and voila, the cached issue was gone. If you have Android Studio you can launch the AVD Manager by following this Create and Manage virtual machine. Otherwise you can wipe the emulator's data using the emulator.exe command line that's included in the android SDK. Simply follow this instructions here Start the emulator from the command line.

    0 讨论(0)
  • 2020-12-09 08:21

    Or you can delete the /build folder under your /app-project folder manually if you cannot run flutter command.

    0 讨论(0)
提交回复
热议问题