Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Flutter hot reload runs but the change does not show

ErrorHot reload was rejected:

Short answer

Hot reload only shows a change when the changed Dart code runs again. Edits to main(), initState(), global variables and static fields need a hot restart. Native code needs a full restart. Only debug mode supports it, and VS Code can save and reload for you if you set two options.

  • Applies to Flutter 3.35, Dart 3.9, VS Code with the Flutter extension
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Press hot restart once. If the change appears, the code you edited does not re-run on reload, and cause 1 applies.

    # VS Code: Cmd+Shift+F5 on macOS, Ctrl+Shift+F5 elsewhere (Flutter: Hot Restart)
  2. 2Match what you see, then jump to its fix

    1. 1Changes in main(), initState(), a global variable or a static field never show upThe edited code does not run again on a reloadFix
    2. 2Edits to Kotlin, Java, Swift or Objective-C do nothingYou changed native code, an enum or a generic typeFix
    3. 3Nothing happens after saving, unless you press the shortcutAuto save and reload on save are not set, or the app is not in debug modeFix

What does the error look like?

  • Hot reload was rejected:
  • The app reloads but the edited value or text stays the same

Cause 1 of 3

The edited code does not run again on a reload

1Check

Hot reload does not re-run main() or initState(), and global variables and static fields are treated as state, so they are not reinitialized.

grep -rn "initState\|static final" lib/

2Fix

Hot restart. For values you change often, use const or a getter instead of final, as the docs suggest.

// not reinitialized on hot reload
final sampleTable = ['a', 'b'];
// changes show after hot reload
const sampleTable = ['a', 'b'];

3Verify

Edit the value, hot reload, and see it change.

# press r in the flutter run terminal

Confirmed by docs.flutter.dev

Did this fix it?

Cause 2 of 3

You changed native code, an enum or a generic type

1Check

Hot reload does not work when an enum becomes a class or the reverse, or when generic type declarations change, and native code needs a full restart.

git diff --stat

2Fix

Stop the app and run it again. A hot restart is not enough for native code.

flutter run

3Verify

The native change is in the new run.

flutter run

Confirmed by docs.flutter.dev

Did this fix it?

Cause 3 of 3

Auto save and reload on save are not set, or the app is not in debug mode

1Check

Only debug-mode apps can be hot reloaded. VS Code reloads on save only with two settings in .vscode/settings.json.

cat .vscode/settings.json

2Fix

Add the settings, and run the app with a debug configuration.

"files.autoSave": "afterDelay",
"dart.flutterHotReloadOnSave": "all",

3Verify

Edit a widget, wait a moment, and it updates without a keypress.

# save the file in VS Code

Confirmed by docs.flutter.dev

Did this fix it?

How do I stop it coming back?

  • Put values you tweak in build methods, not in main() or initState().
  • Restart the app after every native or dependency change.
  • If a reload is rejected, read the first error line and fix that before reloading again.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.