From 4d0dab8c410c00cc31d957e16855a321e2e00699 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Thu, 7 May 2026 20:09:46 -0700 Subject: [PATCH] Trying to get the UI components to update but so far have just broken things. Taking a break. --- lib/main.dart | 51 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index d6aad29..bf00b7b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -131,28 +131,39 @@ class BoardSpot extends StatefulWidget { } class _BoardSpotState extends State { + String _text = ""; + int _spot = 50; + + @override + void initState() { + _spot = widget.spot; + _text = widget.text; + super.initState(); + } + + void _getText() { + setState() { + if (widget.text == "Reset") { + gameReset(); + } + if (widget.spot >= 12) { + null; + } else { + gameTurn(widget.spot, BOARD[widget.spot]); + } + + _text = BOARD[_spot].toString(); + } + } + @override Widget build(BuildContext context) { - return GestureDetector( - // 2. Handle the tap - onTap: () { - // 3. Update the state - setState(() { - if (widget.text == "Reset") { - gameReset(); - } - if (widget.spot >= 12) { - null; - } else { - gameTurn(widget.spot, BOARD[widget.spot]); - } - }); - }, - // 4. The sized box containing the text - child: SizedBox( - width: widget.w, - height: widget.h, - child: Center(child: Text(widget.text, textAlign: TextAlign.center)), + return SizedBox( + width: widget.w, + height: widget.h, + child: TextButton( + onPressed: _getText, + child: Center(child: Text("$_text", textAlign: TextAlign.center)), ), ); }