why flutter hot reload is fast
why flutter hot reload is fast

Hi Guys, Welcome to Proto Coders Point.

In this article we will discuss on why flutter hot reload is faster then android instant run.

Very little difference you may see in flutter hot reload and android Instant run/gradle build

Flutter Hot Reload

The Flutter Framework automatically rebuilds the widget tree, this framework allow you to rapidly boost and reload the changes that your have made in your source code.

When you change flutter dart code and save and send your dart code to get rebuild in your mobile phone where it takes only few seconds or sometime instantly get run.

Hot reload in flutter is so fast because Flutter engine make user of JIT model (just-in_time) for compilation while you run in debug mode, which means that less time is spent in compilation.

But at some point of time, you have to reload/restart your flutter dart code with re-initializes the app’s state

In development mode, Flutter is compiled just-in-time. That is why we can do hot-reload/restart so fast. In release mode (when you go to publish your app), your code is compiled ahead-of-time, to native code. It is for better performace, minimum size and remove other stuff that are useful in dev mode.

What is different between hot reload, hot restart and full restart?

Hot reload: Here it only re build the widget tree where changes has occurred, keeping the app state as it was before hot reload, this does not re run the main() or the initState() of the dart code.

Hot Restart: This will restarts the flutter dart code and it also forget and rebuild the app state, all the previous app state will get lost when hot restart is preformed.

Full restart: In flutter full restart it recompile full project source code for ios, Android, Web that why it may take some longer time because it need to compile the java/Kotlin/objC and swift code etc.

Android Instant run

In android studio instant run same a flutter reload but instant run will always compiles the class fully.

Instant run the VM will checks if a new class change is been made.

Android Studio  instant run will try it’s best to change as little as possible, if it can change some part of classes then it will, but it often needs to replace the entire activity and sometimes the entire app will get rebuilt.

Recommended Flutter Articles

Pros of Flutter. Why flutter app development is best?

Future of Flutter app development

Why is Flutter trending in 2021

1 Comment