use setstate in stateless code example
Example 1: setstate flutter
setState(() { _myState = newValue; });
Example 2: stateless widget flutter
class GreenFrog extends StatelessWidget {
const GreenFrog({ Key key }) : super(key: key);
Widget build(BuildContext context) {
return Container(color: const Color(0xFF2DBD3A));
}
}