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.
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.