You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support hot-reload / hot-restart using vm service protocol #2708
The Dart VM Service protocol now supports hot reload and hot restart, meaning Dart command line apps should support proper code hot reloading. It would be nice if Dart-Code utilized this method instead of relying on the flutter tool.
@bkonyi should there be something like a reloadSources service/extension registered when running a Dart script? I can see the VM Service has a reloadServices method, but in Flutter we use the presence of reloadSources and hotRestart services to know when these are available. Should there be similar for Dart, or should we assume it's always available for a recent SDK?
(Also, the original issue here mentions Restart too - but I don't see anything in the docs about that - is it also available through the Dart VM without Flutter?)
It would be good to support Hot Reload still - but it'd be nice to do it consistently with Flutter (eg. we use the presence of some VM Service to know it's available, and call it via that service) so the extension doesn't need to have logic about when it may/may not be available.
Correct, the service protocol doesn't actually implement Hot Restart. That's solely a Flutter extension of the protocol. The VM service protocol does support reloadSources, which is the RPC to trigger a hot reload.
There's now an additional command Dart: Hot Reload which will call reloadSources for each isolate when debugging non-Flutter apps:
Actually, Flutter: Hot Reload and Dart: Hot Reload call the same thing (so using either will have the same effect), it's the debug adapter that actually controls which code is run. For Flutter, we need to go through Flutter because otherwise I think some code to rebuild the widget tree could be skipped.
Reacted by Dan Dinh
Reacted by Maksim Lin, Luis, Tim Whiting, nbros, Nick Rebbok, Jr Bytes and Nero Song
@fuzzybinary right now you have to run the command. I'm not sure I'd want to enable it by default, although perhaps we could add a dart.hotReloadOnSave (similar to dart.flutterHotReloadOnSave)? If that would be useful, please file an issue and I'll have a look at getting it into the next release.
Actually, there's probably some inconsistency here.. If you run a Flutter app and a Dart app at the same time, saving a file probably will reload both, because it will unconditionally send the request to both. So if we were to support both, we should probably improve that too.
Supporting hot-reload-on-save properly turns out to be a bit trickier than I thought and will require some refactoring, so I'm going to leave that until the next release (I've filed #3637). In the meantime, I'm going to ensure the Dart reload is not fired by Flutter's reload-on-save, because it could be unreliable (for example it would not debounce if Flutter supports its own internal debounce, which would result in it triggering a lot when you do things like Save All).
Reacted by Leonardo da Silva and mono — Masayuki Ono
@danddinh the command only shows up while you're in a Dart debugging session - is that the case? (you should be able to see the debug toolbar when this is the case, and the status bar usually changes colour).
The option is shown and show alert about starting a debug session.
It's not clear to me why you would want to invoke this command when you're not in a debug session. There's a lot of things in the command palette and adding entries that don't make sense in the current context are just additional things that might show up top when you're trying to invoke something else (for example "Reload Window" or "Reload Webviews")
Maybe a note in the README.md of the extension for Antie/VSCode should be nice instead. Coz new users of the extension won't know there's such 'Dart: Hot Reload' feature.
Activity
Switch to using the VM Service for calling services/extensions instea…
Switch to using the VM Service for calling services/extensions instea…
DanTup commentedon Sep 27, 2021
@bkonyi should there be something like a reloadSources service/extension registered when running a Dart script? I can see the VM Service has a
reloadServicesmethod, but in Flutter we use the presence ofreloadSourcesandhotRestartservices to know when these are available. Should there be similar for Dart, or should we assume it's always available for a recent SDK?(Also, the original issue here mentions Restart too - but I don't see anything in the docs about that - is it also available through the Dart VM without Flutter?)
fuzzybinary commentedon Sep 29, 2021
I may have been mistaken about the ability to do Hot Restart without Flutter.
DanTup commentedon Sep 29, 2021
Ah, got it.
It would be good to support Hot Reload still - but it'd be nice to do it consistently with Flutter (eg. we use the presence of some VM Service to know it's available, and call it via that service) so the extension doesn't need to have logic about when it may/may not be available.
bkonyi commentedon Sep 29, 2021
Correct, the service protocol doesn't actually implement Hot Restart. That's solely a Flutter extension of the protocol. The VM service protocol does support
reloadSources, which is the RPC to trigger a hot reload.2 remaining items
DanTup commentedon Oct 26, 2021
There's now an additional command Dart: Hot Reload which will call reloadSources for each isolate when debugging non-Flutter apps:
Actually, Flutter: Hot Reload and Dart: Hot Reload call the same thing (so using either will have the same effect), it's the debug adapter that actually controls which code is run. For Flutter, we need to go through Flutter because otherwise I think some code to rebuild the widget tree could be skipped.
fuzzybinary commentedon Oct 26, 2021
Does this work with reload on save or do you have to manually trigger the reload?
DanTup commentedon Oct 26, 2021
@fuzzybinary right now you have to run the command. I'm not sure I'd want to enable it by default, although perhaps we could add a
dart.hotReloadOnSave(similar todart.flutterHotReloadOnSave)? If that would be useful, please file an issue and I'll have a look at getting it into the next release.(btw there's a beta with the above command available at https://github.com/Dart-Code/Dart-Code/releases/tag/v3.28.0-beta.1 if you want to try it out before the release)
DanTup commentedon Oct 26, 2021
Actually, there's probably some inconsistency here.. If you run a Flutter app and a Dart app at the same time, saving a file probably will reload both, because it will unconditionally send the request to both. So if we were to support both, we should probably improve that too.
DanTup commentedon Oct 27, 2021
Supporting hot-reload-on-save properly turns out to be a bit trickier than I thought and will require some refactoring, so I'm going to leave that until the next release (I've filed #3637). In the meantime, I'm going to ensure the Dart reload is not fired by Flutter's reload-on-save, because it could be unreliable (for example it would not debounce if Flutter supports its own internal debounce, which would result in it triggering a lot when you do things like Save All).
Only hot reload Flutter on-save
danddinh commentedon Oct 15, 2026
2026, I installed the Dart extension (by Dart-Code) in VS Code but there no
Dart: Hot Reloadin command palette (Ctrl+Shift+P).How to enable that command?
FMorschel commentedon Oct 15, 2026
@danddinh, are you sure your Dart project was detected?
DanTup commentedon Oct 15, 2026
@danddinh the command only shows up while you're in a Dart debugging session - is that the case? (you should be able to see the debug toolbar when this is the case, and the status bar usually changes colour).
danddinh commentedon Oct 15, 2026
My app dir has just these:
Seems it's not detectable?
DanTup commentedon Oct 15, 2026
@danddinh are you in a debugging session started through VS Code?
If so, please file a new issue with exact steps so we can try to reproduce what you're seeing. Thanks!
danddinh commentedon Oct 15, 2026
Ah yes, the Debug Start button.
I now know how: edit
.vscode/launch.jsonand click the Debug Start button.However, for those don't have the clue to start as in my case, I guess this behaviour should be there:
DanTup commentedon Oct 15, 2026
It's not clear to me why you would want to invoke this command when you're not in a debug session. There's a lot of things in the command palette and adding entries that don't make sense in the current context are just additional things that might show up top when you're trying to invoke something else (for example "Reload Window" or "Reload Webviews")
danddinh commentedon Oct 15, 2026
Maybe a note in the README.md of the extension for Antie/VSCode should be nice instead. Coz new users of the extension won't know there's such 'Dart: Hot Reload' feature.
FMorschel commentedon Oct 15, 2026
Using the debug palette, restart and lightning buttons that are really visible, you get the same result.