1
votes

What is the correct way to acces a StatefulWidget's State from within the StatefulWidget?

I have tried having a instance variable in the StatefulWidget class and setting that with "widget._state = this;" in the "initState()" method in my State class, but sometimes it is null?

Thank you
Søren

1

1 Answers

0
votes

That is not possible, no.

StatefulWidget is purely immutable. It cannot contain anything mutable.