Can somebody explain the usage of <MyApp>
?
MyAppState is extended of State class , but what is MyApp?
I know OOP in php but can't understand this one.
class MyApp extends StatefulWidget{
@override
MyAppState createState() => new MyAppState();
}
class MyAppState extends State<MyApp>{
@override
Widget build(BuildContext context) {
return new Scaffold(...);
}
}
Always remember that State<T>
class is implemented as a generic class
when you extend any generic class you have to specify the type for it which happen to be your statful widget concrete implementation and its name is MyApp
for every concrete implementation for the StatfulWidget
class you need to define another concrete implementation of a class extending State<MyApp>
and its name is MyAppState
because State<T>
is a generic class we code it as State<MyApp>
so as answer to your question
MyApp is the name of the concrete implementation of the class StatefulWidget
StatefulWidget -----> class not generic
MyApp -------------> concrete implementation for StatefulWidget class
State -----------> generic class of
MyAppState --> concrete implementation for State
Hope that help ..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With