generated from me/template-mit
Got the UI to update for the button being pressed! Other buttons are not getting updated yet though.
This commit is contained in:
+8
-6
@@ -141,19 +141,21 @@ class _BoardSpotState extends State<BoardSpot> {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void _getText() {
|
||||
setState() {
|
||||
void _playBoardSpot() {
|
||||
logger.d(method: "_playBoardSpot", "Playing spot '$_spot'");
|
||||
setState(() {
|
||||
logger.d(method: "_playBoardSpot", "Inside setState()");
|
||||
if (widget.text == "Reset") {
|
||||
gameReset();
|
||||
}
|
||||
if (widget.spot >= 12) {
|
||||
null;
|
||||
} else {
|
||||
gameTurn(widget.spot, BOARD[widget.spot]);
|
||||
gameTurn(_spot, BOARD[_spot]);
|
||||
}
|
||||
|
||||
_text = BOARD[_spot].toString();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -162,8 +164,8 @@ class _BoardSpotState extends State<BoardSpot> {
|
||||
width: widget.w,
|
||||
height: widget.h,
|
||||
child: TextButton(
|
||||
onPressed: _getText,
|
||||
child: Center(child: Text("$_text", textAlign: TextAlign.center)),
|
||||
onPressed: _playBoardSpot,
|
||||
child: Center(child: Text(_text, textAlign: TextAlign.center)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user