Flutter hot reload runs but the change does not show
Hot 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.
Fix it fast
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)2Match what you see, then jump to its fix
- 1
Changes in main(), initState(), a global variable or a static field never show upThe edited code does not run again on a reloadFix - 2
Edits to Kotlin, Java, Swift or Objective-C do nothingYou changed native code, an enum or a generic typeFix - 3
Nothing happens after saving, unless you press the shortcutAuto save and reload on save are not set, or the app is not in debug modeFix
- 1
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 terminalConfirmed by docs.flutter.dev
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 --stat2Fix
Stop the app and run it again. A hot restart is not enough for native code.
flutter run3Verify
The native change is in the new run.
flutter runConfirmed by docs.flutter.dev
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.json2Fix
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 CodeConfirmed by docs.flutter.dev
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Qist BazaarA buy-now-pay-later marketplace built from a blank repo, now past 100K downloads on Google Play.
- SessionBirdAn omnichannel engagement suite in Flutter: campaigns, chatbot, tickets, analytics and live calling.
Related fixes
Mobile apps
AudioCache has no play method after updating audioplayers
The method 'play' isn't defined for the type 'AudioCache'.
Since audioplayers 1.0, AudioCache only turns asset files into local files and caches them.
2 causes, each with a fixMobile apps
Flutter Bloc throws that emit was called after the event handler completed
emit was called after an event handler completed normally.
Each on<Event> handler gets its own Emitter, and it stops working the moment the handler's returned Future completes.
2 causes, each with a fixMobile apps
analysis_options.yaml: the URI it includes can't be found
include_file_not_found
The analyzer reports include_file_not_found when the file named after include: in analysis_options.yaml does not resolve.
2 causes, each with a fixMobile apps
Dart error: the body might complete normally and return null for a non-nullable type
body_might_complete_normally
Dart found a path through your function or callback that reaches the closing brace without a return.
3 causes, each with a fixMobile apps
Dart throws ConcurrentModificationError while looping over a list
ConcurrentModificationError
Dart throws this when a collection changes size while something iterates it.
2 causes, each with a fixMobile apps
Dart cannot turn a compact timestamp like 20201101153000 into a DateTime
FormatException: Invalid date format
DateTime.parse accepts a subset of ISO 8601, and a time part must be introduced by T or a space.
2 causes, each with a fix