8

Flutter hot reloads every time VS Code auto-saves my project before. A few hours ago, I started experiencing this issue where auto-saving doesn't hot-reload my app. Pressing Ctrl+S manually triggers hot reload but auto-saving does not. I've tried re-installing VS Code and Flutter SDK but the problem still exists.

My newly installed VS Code only has the following extensions and settings:

Dart: v3.19.1
Flutter: v3.19.0
Auto-save is set to afterDelay of 1000ms

How do I hot reload when autosaving in vscode? Another person had the same issue two hours ago: https://github.com/Dart-Code/Dart-Code/issues/3110

CoderUni
  • 5,474
  • 7
  • 26
  • 58

3 Answers3

16

An update in Dart & Flutter's VS Code extension is causing the issue.

===== Latest Version =====

3.42 and above: You can enable hot reload on autosave in the latest version by setting Flutter Hot Reload On Save to allIfDirty in your VSCode settings.

===== Old Versions =====

v3.41 and below: You can enable hot reload on autosave in the latest version by setting Flutter Hot Reload On Save to always in your VSCode settings.

v3.19: They disabled hot reload on autosave completely.

v3.18 and below: The extension hot reloads automatically when auto saving.

CoderUni
  • 5,474
  • 7
  • 26
  • 58
  • I can't understand why you want auto-save to trigger a hot reload... that'd mess up your debugging! (Not every change results in a valid syntax, or a hot-reloadable source text.) – Randal Schwartz Jan 31 '21 at 05:43
  • @RandalSchwartz Its more of preference. It makes development a lot easier since it only hot reloads when the compiler doesn't detect any errors in the code – CoderUni Jan 31 '21 at 05:52
  • 1
    @RandalSchwartz I agree with Uni. It's a nice feature I must say. Just disable auto-save if you have to CTRL + S every time – akifarhan Feb 02 '21 at 11:15
  • @akifarhan They are going to have a setting in the next release. You can follow the github issue above for updates – CoderUni Feb 02 '21 at 15:17
3

It's in the change notes for this release. It's an intended feature! (http://dartcode.org/releases/v3-19)

It says:

#3033: Hot-reload-on-save no longer fires for Save events triggered by VS Code’s auto-save feature. Pressing Save manually will still trigger a reload even if there are no unsaved changes.

starball
  • 20,030
  • 7
  • 43
  • 238
Randal Schwartz
  • 39,428
  • 4
  • 43
  • 70
0
Just delete your VS cache folder and VS temp folder.
-> Press windows button and type:

%temp%

%appdata%

-> Check your launch.json in .vscode folder. delete and recreate if necessary.
  • I've tried that as well and it didn't work. The devs told me that it was caused by the latest version of dart and flutter extension. – CoderUni Jan 31 '21 at 05:07