Here is property
as a part of the StatefulWidget
class
class MyWidget extends StatefulWidget {
String property = "";
@override
State<MyWidget> createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
@override
Widget build(BuildContext context) {
return Container();
}
}
Here is how I would accessproperty
from the State
's build
method:
widget.property
Here is property
as a part of the StatefulWidget
's State
class
class MyWidget extends StatefulWidget {
@override
State<MyWidget> createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
String property = "";
@override
Widget build(BuildContext context) {
return Container();
}
}
Here is how I would access it from the State
's build
method:
property
Looks to me like I can achieve the exact same things regardless of whether property
is part of the StatefulWidget
class or part of the State
class.
Am I right or wrong, and if I am wrong, why?