Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Another exception was thrown: type 'MyApp' is not a subtype of type 'StatelessWidget'

As Jonah Williams said,

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.


you need to restart your app for the changes to take effect. Hot reload won't work at this time


You need to Hot Reload by using R (shift + r) coz you change MyApp class from StatelessWidget to a StatefulWidget while your app is running.


In the flutter If you need to change MyApp then you can not get result when after the app reloaded .You must need to restart you app and then you can check your edits are available on the app.


Since StatelessWidget was used at the begining of the code and was latter changed to a StatefulWidget you need to hot restart. It will continue to give error if you don't restart it because initially it's invoked in main