To enable hot reload on save in Flutter, you can configure your editor or IDE to automatically trigger a hot reload whenever you save a file. Here’s how you can do this in different environments:

Visual Studio Code (VS Code)

  1. Install the Flutter and Dart plugins: Ensure you have the Flutter and Dart extensions installed in VS Code.
  2. Set up auto-save: You can configure VS Code to save files automatically. Go to File > Preferences > Settings, search for “Files: Auto Save”, and set it to afterDelay or any other option that suits you.
  3. Flutter settings in VS Code: By default, the Flutter extension performs a hot reload whenever you save a file. You can check or modify this behavior:
    • Open Command Palette (Ctrl+Shift+P or Cmd+Shift+P on Mac) and type “Preferences: Open Settings (JSON)”.
    • Add the following setting to ensure hot reload on save:

"dart.flutterHotReloadOnSave": true

Android Studio / IntelliJ IDEA

  1. Install the Flutter and Dart plugins: Ensure you have the Flutter and Dart plugins installed in your IDE.
  2. Enable auto-save: Go to File > Settings > Appearance & Behavior > System Settings, and check the Save files automatically if application is idle for X sec option.
  3. Flutter settings in Android Studio: By default, the Flutter plugin for Android Studio/IntelliJ IDEA should hot reload on save. If it does not, you can enable this feature:
    • Go to File > Settings > Languages & Frameworks > Flutter.
    • Ensure that Perform hot reload on save is checke

Command Line (Terminal)

If you are using a terminal to run your Flutter app, you can manually trigger a hot reload by typing ‘r’ in the terminal where ‘flutter run’ is executed.

While automatic hot reload on save is not configured directly in the terminal, you can set up a file watcher tool (e.g., watchman) to monitor changes in your files and trigger commands automatically. This requires more advanced configuration and is less common compared to using an IDE with built-in support.

Other option:

A short and sweet vim plugin that triggers Hot Reload every time you save a dart file.

To install, use your favourite plugin manager.

I use vim-plug:
Plug 'reisub0/hot-reload.vim'

There’s no need for a pid-file flag anymore, due to getting the pid of the flutter process dynamically.

Then, every time you save the file, Hot reload will be automatically triggered by sending a SIGUSR1 to flutter.

Support On Demand!

Flutter