How To Enable Hot Reload For Flutter Web

Flutter category image

Introduction

Mobile apps already benefit from it. Next in line is Flutter web. So here is how to enable hot reload for Flutter web apps!

Debugging web apps has always been a little painful for me. Imagine you have multiple menus and nested screens. Any change resulted in a hot restart and you had to navigate to the previous screen again to see if the changes were applied. But things are about to get better!

Recently, the Flutter team added hot reload capabilities for the web platform. In Flutter 3.32, it is not enabled by default. You have to manually set a flag when running the app.

Run the app from the command line:

Bash
flutter run -d chrome --web-experimental-hot-reload

Or adjust your launch.json config file in VS Code by changing the args value:

Dart
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "xxx",
            "request": "launch",
            "type": "dart",
            "args": ["--web-experimental-hot-reload"]
        },
        {
            "name": "xxx (profile mode)",
            "request": "launch",
            "type": "dart",
            "flutterMode": "profile",
            "args": ["--web-experimental-hot-reload"]
        },
        {
            "name": "xxx (release mode)",
            "request": "launch",
            "type": "dart",
            "flutterMode": "release",
            "args": ["--web-experimental-hot-reload"]
        }
    ]
}

Changes are visible immediately and the need for a hot restart is gone for 99% of use cases!

Drawback

I found one small little problem with this feature. I usually develop on Windows and Microsoft Edge is my main debugging browser. However, hot reload does not work in this case. The debugging bar doesn’t show the hot reload symbol (yellow flash).

When running on the Microsoft Edge browser, the hot reload symbol is missing.
When running on the Microsoft Edge browser, the hot reload symbol is missing.

With Google Chrome, everything works as promised. The button is available and the feature behaves as you would expect it to do.

When running on the Google Chrome browser, the hot reload symbol (yellow flash) is available and working.
When running on the Google Chrome browser, the hot reload symbol (yellow flash) is available and working.

Conclusion

In this article, I showed you how to enable hot reload in Flutter web apps. It makes your development experience more seamless.


Want More Flutter Content?

Join my bi-weekly newsletter that delivers small Flutter portions right in your inbox. A title, an abstract, a link, and you decide if you want to dive in!

Flutter ❤️ Firebase

Get started with Firebase and learn how to use it in your Flutter apps. My detailed ebook delivers you everything you need to know! Flutter and Firebase are a perfect match!

Become A Testing Expert!

Become a proficient Flutter app tester with my detailed guide. This ebook covers everything from unit tests over widget tests up to dependency mocking.