Why is the build () method on state and not StatefulWidget?

Why is the build method on State, and not StatefulWidget? Putting a Widget build(BuildContext context) method on State rather than putting a Widget build(BuildContext context, State state) method on StatefulWidget gives developers more flexibility when subclassing StatefulWidget.

Sizin İçin Seçtik  Are static classes better?

Leave a Reply

Your email address will not be published. Required fields are marked *

Why is the build method on state and not StatefulWidget?

1 Answer. The reason why StatefulWidget uses a separate State class and not having build method inside its body is because all fields inside a Widget are immutable , and this includes all its sub-classes.

Sizin İçin Seçtik  What is widget build?

Leave a Reply

Your email address will not be published. Required fields are marked *