Today when I was writing few lines of code in Flutter in theme property of MaterialApp widget. Then I saw a large error regarding "The constructor being called isn't a const constructor. Try removing 'const' from the constructor invocation.". I was seeing this error for the first time. So I have visited the official dart code explanation page from HERE and read the documentation.
Why constructor being called isn't a const constructor error come in dart?
Const keywords are required constant values because they are hard coded but In the code I am creating a dynamic widget which is not a constant.
Error Screenshot:
Flutter The constructor being called isn't a const constructor Error Fix:
To resolve this error all you have to do is remove const keyword from the beginning of MaterialApp widget
return MaterialApp(
home: HomeScreen(),
);
Comments
Post a Comment