Trying to get the UI components to update but so far have just broken things. Taking a break.

This commit is contained in:
2026-05-07 20:09:46 -07:00
parent 58b8ab9253
commit 4d0dab8c41
+31 -20
View File
@@ -131,28 +131,39 @@ class BoardSpot extends StatefulWidget {
} }
class _BoardSpotState extends State<BoardSpot> { class _BoardSpotState extends State<BoardSpot> {
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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return SizedBox(
// 2. Handle the tap width: widget.w,
onTap: () { height: widget.h,
// 3. Update the state child: TextButton(
setState(() { onPressed: _getText,
if (widget.text == "Reset") { child: Center(child: Text("$_text", textAlign: TextAlign.center)),
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)),
), ),
); );
} }