[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 AllWhat want to do I want to create an input form using TextField. For example, if the input content is a monetary amount, I would like to...
What want to do There is a variable that remain unchanged once the initial value is determined. However, it cannot be determined yet when...
What want to do As the title suggests. Place two widgets in one line on the screen One in the center of the screen and the other on the...
Comments