TechnicalEasy Flutter
What is the difference between hot reload and hot restart in Flutter?
Asked for Mobile Developer
Why they ask this: A practical question that shows real hands-on Flutter experience.
Answer
- Hot reload injects your changed code into the running Dart VM and rebuilds the widget tree while keeping the app state (for example the current screen and form input). It takes about a second and is ideal for UI tweaks.
- Hot restart reloads the code and restarts the app from
main(), so all state is lost. It is still faster than a full rebuild. - A full restart (stop and run) is needed for native changes: new plugins with platform code,
AndroidManifest.xmlorInfo.plistedits, and some asset changes.
Hot reload will not pick up changes to main(), initState() logic that already ran, global or static variable initialisers, or enum and generic type changes. Use hot restart for those.
Can you explain this in your own words?