📜  类型“MyApp”不是类型转换中“StatelessWidget”类型的子类型 - 无论代码示例

📅  最后修改于: 2022-03-11 14:57:51.132000             🧑  作者: Mango

代码示例1
If you changed MyApp from a StatelessWidget to a StatefulWidget you need to hot restart, since it is invoked in main

This has been explained multiple times in live coding sessions, that when you make changes in functions like initState(), you have to restart the app. A similar case applies for you, when you changed state related properties of the MyApp widget you need to restart your app for those changes to take effect.

Basically, when you hot reload the app, it calls the build() function, initState() is called only when you restart the app, so that the app reinitiates everything including the widget whose initState() function you changed.