Why doesn't the widget rebuild with the setState function?

48 views Asked by At

I would like to rebuild the widget, when the value of the variable 'player' changes. The variable 'player' is a global variable. The class spielerAnzeige is a stateful widget and i also called setState but nothing happens.

class spielerAnzeige extends StatefulWidget {
  @override
  State<spielerAnzeige> createState() => _spielerAnzeigeState();
}

class _spielerAnzeigeState extends State<spielerAnzeige> {
  Widget build(BuildContext context) {
    setState(() {});
    return Text("Spieler $player ist an der Reihe!",
        style: TextStyle(fontSize: 40));
  }
}
0

There are 0 answers