简体   繁体   中英

VS Code Flutter auto hot reload not working after updating

After I updated my Dart extension in VS Code, it doesn't automatically hot-reload my Flutter codes even though I've turned on autosave. Does anyone have an idea about how to solve it?

Run the flutter doctor command and make sure that flutter is installed properly on your machine.

Which channel are you running on? Make sure that you run on the stable channel, as long as it does not give you any compile time issues.

If the flutter doctor works, then make sure that, if you are running on iOS (Physical Device), that you have bonjour service enabled. This is required in order to make debugging work on physical devices (for iOS 14+). Please also make sure that you add -v command to the end of your deploy function, to increase the log verbosity. Otherwise you can just deploy to the simulator.

If you are running on Android, there should not be any issues, unless there is a problem with the logcat. In this case you can try to go to android Studio and reboot the ADB (Android Debug Bridge), in which case the machine will try to reattach a debuggable process to your device. If it's still not working, then try another device. If that's not working, then add the -v command, I mentioned earlier, about log verbosity.

Post an update on your issue, once you have tried all of these suggestions.

[ EDIT ] Please make sure that hot reload is enabled on the vscode settings. Go to Settings > Search > Hot Reload, and make sure it's enabled for both Auto Save & Restart.

Please take a look at this image below: 在此处输入图像描述

[EDIT ONCE AGAIN] If you look at the flutter documentation ( https://flutter.dev/docs/development/tools/hot-reload ) it says, that to run a flutter hot reload, you have to follow these steps:

Run the app from a supported Flutter editor or a terminal window. Either a physical or virtual device can be the target. Only Flutter apps in debug mode can be hot reloaded. Modify one of the Dart files in your project. Most types of code changes can be hot reloaded; for a list of changes that require a hot restart, see Special cases. If you're working in an IDE/editor that supports Flutter's IDE tools, select Save All (cmd-s/ctrl-s), or click the hot reload button on the toolbar.

Make sure that you follow all the steps in the documentation, then let's talk on this post again ( https://flutter.dev/docs/development/tools/hot-reload )

If you using VS Code, Go to the Settings > Extensions > Dart & Flutter

Then select always in Flutter Hot Reload On Save

Congrats Your problem is solved.

PFA screenshot here

Asked and answered over here: Flutter doesn't hot reload on autosave in VSCode . In short, it is working as designed .

The "hot reload on save" feature was intended to run when the user specifically pressed save so they had some control over when it occurred. Some users experienced issues where autosave would cause it to fire when they didn't want it to, so this "bug" was recently fixed.

It turns out that for many users, hot-reload-on-autosave worked fine, so the next version of the Dart extension will include a setting to allow you to re-enable that.

"dart.flutterHotReloadOnSave": "always"

For VS Code Go to 'File' -> 'Auto Save' make sure you have "check" Auto Save.

If you're running the app at the command line using

flutter run

command, enter r in the terminal window to hot reload.

Try to run by clicking Run button worked in my case.

Like this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM