generated from me/template-mit
Trying to get the UI components to update but so far have just broken things. Taking a break.
This commit is contained in:
+22
-11
@@ -131,13 +131,18 @@ class BoardSpot extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _BoardSpotState extends State<BoardSpot> {
|
class _BoardSpotState extends State<BoardSpot> {
|
||||||
|
String _text = "";
|
||||||
|
int _spot = 50;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
void initState() {
|
||||||
return GestureDetector(
|
_spot = widget.spot;
|
||||||
// 2. Handle the tap
|
_text = widget.text;
|
||||||
onTap: () {
|
super.initState();
|
||||||
// 3. Update the state
|
}
|
||||||
setState(() {
|
|
||||||
|
void _getText() {
|
||||||
|
setState() {
|
||||||
if (widget.text == "Reset") {
|
if (widget.text == "Reset") {
|
||||||
gameReset();
|
gameReset();
|
||||||
}
|
}
|
||||||
@@ -146,13 +151,19 @@ class _BoardSpotState extends State<BoardSpot> {
|
|||||||
} else {
|
} else {
|
||||||
gameTurn(widget.spot, BOARD[widget.spot]);
|
gameTurn(widget.spot, BOARD[widget.spot]);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
},
|
_text = BOARD[_spot].toString();
|
||||||
// 4. The sized box containing the text
|
}
|
||||||
child: SizedBox(
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SizedBox(
|
||||||
width: widget.w,
|
width: widget.w,
|
||||||
height: widget.h,
|
height: widget.h,
|
||||||
child: Center(child: Text(widget.text, textAlign: TextAlign.center)),
|
child: TextButton(
|
||||||
|
onPressed: _getText,
|
||||||
|
child: Center(child: Text("$_text", textAlign: TextAlign.center)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user