top of page

[Flutter/Dart] Hot Restart builds the whole app twice


Phenomenon

When hot restart the Flutter

runApp(MyApp());

runs twice (checked with debugger).

It seems this issue is only for Hot Restart.



Cause

I don't know the exact cause, but it seems to be a specification of the Flutter framework.



Countermeasures

Design the app so that the whole app can be rebuilt twice (or more).

Not only for this, when using Flutter, rebuild process runs often unexpectedly, so it is not desirable to create a function that depends on the number of builds.


For example, in the case of process such as caching the calculation result at the first build and reusing it in the second and subsequent rebuilds, be careful to set the flag of "calculated or not" and the storage destination of the calculation result, otherwise the calculation may not be performed even though it is the first time.


Reference

Recent Posts

See All

Comments


category

Let's do our best with our partner:​ ChatReminder

iphone6.5p2.png

It is an application that achieves goals in a chat format with partners.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png

Let's do our best with our partner:​ ChatReminder

納品:iPhone6.5①.png

It is an application that achieves goals in a chat format with partners.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png

Theme diary: Decide the theme and record for each genre

It is a diary application that allows you to post and record with themes and sub-themes for each genre.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png
bottom of page