Sub topic 10
When Only a Full Restart Works
Assume you can run a Flutter app in debug mode and understand the difference between a widget and a State object. A full restart means stopping the running app and starting it again with a new flutter run process. It rebuilds the application and reconnects the debugger from the beginning.
Hot restart already reruns Dart startup code and clears Dart state. A full restart goes further: it also stops the Flutter engine and rebuilds or reloads native platform code and app configuration.
Changes That Need a Full Restart
Use a full restart when your edit cannot be applied to the running Dart isolate or Flutter engine. Common examples include:
- Changes to Android or iOS native code.
- Changes to plugin registration or a plugin's native implementation.
- Changes to
AndroidManifest.xmlorInfo.plist. - Changes to Gradle files, the Android build configuration, or the iOS
Podfile. - Changes to native permissions, URL schemes, app services, or platform channels.
- Adding or removing a package that contains native code.
- Changes that require a new native build artifact.
- Changes to the selected device, platform, architecture, or build configuration.
For example, changing a Dart call to a platform channel can be handled by hot reload. Changing the Kotlin, Swift, or Objective-C method on the other side of that channel requires a new native build.
# Stop the current flutter run process with q or Ctrl+C.
flutter clean
flutter pub get
flutter runYou do not always need flutter clean. It can help when stale generated files or build artifacts prevent the new configuration from being used. Start with a normal stop and run cycle. Use flutter clean only when the build remains stale or fails in a way that points to cached output.
Full Restart Compared with Hot Restart
The actions have different scopes:
| Action | Dart code | Dart state | Native code and configuration |
|---|---|---|---|
| Hot reload | Applies many changes | Keeps existing `State` objects | Does not rebuild it |
| Hot restart | Starts Dart again | Resets Dart state | Usually keeps the existing native build |
| Full restart | Starts the app and Dart again | Resets all runtime state | Rebuilds or reloads native output |
A hot restart is enough for a changed main function, a changed global initializer, or a value assigned in initState. A full restart is needed when those Dart changes depend on a changed native build or platform configuration.
A Reliable Diagnosis
When a change does not appear, check the change's boundary:
- Confirm that the file is part of the running target. An unused file or a different flavor will not affect the screen.
- Check the terminal for compile errors after the reload.
- Try hot reload if the edit only changes
buildor another ordinary Dart method. - Try hot restart if the edit changes
main, a global initializer, orinitState. - Stop the app and run it again if the edit touches native files, plugin code, dependencies with native code, or platform configuration.
- Rebuild generated files or clean the build only when the normal full restart still uses stale output.
A full restart does not fix a logic error. If the new build starts but the screen is unchanged, inspect routes, conditional branches, feature flags, and the active build flavor.
> callout warning > A full restart resets in-memory data. Save important test data before stopping the app, especially when the app stores temporary state only in memory.
Platform and Build-Mode Limits
Hot reload and hot restart are debug-development features. They are not a model for release behavior. Release and profile builds use different compilation and deployment rules, so changes generally require a new build and installation.
Native changes can also take longer because Flutter must invoke Gradle, Xcode, CocoaPods, or another platform build system. That delay is expected. The key signal is whether the changed code belongs to Dart running inside the current engine or to the native application surrounding it.
Exercise
You changed a Swift method used by a Flutter platform channel. Which action should you take, and why?
Show answer
Stop the app and run it again. The Swift code is native code, so hot reload and hot restart cannot replace the native build currently loaded by the Flutter engine.