When the stateless widget is used, the statCalling setState() is critical, because this tells the framework that the widget’s state has changed and that the widget should be redrawn. code example

Example: flutter stateful widget

class YellowBird extends StatefulWidget {
  const YellowBird({ Key key }) : super(key: key);

  
  _YellowBirdState createState() => _YellowBirdState();
}

class _YellowBirdState extends State<YellowBird> {
  
  Widget build(BuildContext context) {
    return Container(color: const Color(0xFFFFE306));
  }
}

Tags:

Dart Example