1

Scenario

I'm working through the base counter app (after flutter create)

Expected Functionality

I want to enable hot reload in VS Code:

1. increase the count
2. change the primary color + save file
3.1 see the color change
3.2 see the count stay the same (preserving state)

Actual Behavior

In all cases (saving, hitting r(R) in the console, even hitting the lightning icon) I get a Restarted application in Xms and a hot restart.

1. increase the count
2. change the primary color + save file
3.1 color changes
3.2 count is reset to 0 (state is lost)

What I tried

  • switching between manual and automatic save settings
  • setting dart.flutterHotReloadOnSave to all
  • setting dart.hotReloadOnSave to all
  • launching the app in debug and run modes (ctrl+F5 and F5)

My setup

  • Flutter v3.3.2
  • VS Code v1.71
  • Flutter extension v3.48.0
  • Dart extension v3.48.3

1 Answer 1

2

Hot Reload is only available for non-web devices (desktop, mobile). On web, any calls to Hot Reload will instead trigger Hot Restart (since it's the closest functionality available).

Hot Reload for web is tracked in this issue: https://github.com/flutter/flutter/issues/53041

3
  • As described in the question I tried running the app through VS Code and through the terminal in debug/run modes. I also tried hitting the lightning button. Neither approaches result in a hot reload.
    – ANDREYDEN
    Commented Oct 7, 2022 at 16:09
  • @ANDREYDEN apologies, I saw you mention Shift+R and had assumed you'd only been running from the terminal. Re-reading I see the issue is that you're getting a Hot Restart when you expect a Hot Reload. Can you confirm what device you're running on? Right now, web/Chrome does not support a stateful reload, so all reloads will be a full restart unfortunately. This is tracked in github.com/flutter/flutter/issues/53041 Commented Oct 8, 2022 at 17:20
  • That makes a lot of sense! I've tried this on an Android emulator and it worked. Do you mind re-posting/editing your answer so I can mark it as accepted?
    – ANDREYDEN
    Commented Oct 10, 2022 at 20:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.