Playing with the callback but still not having any luck.

This commit is contained in:
2026-05-21 14:35:12 -07:00
parent b3e955b38a
commit 3aae269460
+28 -5
View File
@@ -60,7 +60,15 @@ class _GameBoardState extends State<GameBoard> {
children: [ children: [
// Player 1 Goal // Player 1 Goal
Column( Column(
children: [Center(child: PlayerSpot(spot: 0, board: _BOARD))], children: [
Center(
child: PlayerSpot(
spot: 0,
board: _BOARD,
boardUpdate: updateBoard,
),
),
],
), ),
// Center holes // Center holes
Column( Column(
@@ -210,7 +218,15 @@ class _GameBoardState extends State<GameBoard> {
), ),
// Player 2 Goal // Player 2 Goal
Column( Column(
children: [Center(child: PlayerSpot(spot: 07, board: _BOARD))], children: [
Center(
child: PlayerSpot(
spot: 07,
board: _BOARD,
boardUpdate: updateBoard,
),
),
],
), ),
], ],
); );
@@ -222,7 +238,7 @@ class BoardSpot extends StatefulWidget {
final List<int> board; final List<int> board;
final double w; final double w;
final double h; final double h;
final ValueChanged<List<int>>? boardUpdate; final ValueChanged<List<int>> boardUpdate;
BoardSpot({ BoardSpot({
super.key, super.key,
@@ -263,6 +279,7 @@ class _BoardSpotState extends State<BoardSpot> {
BOARD = gameTurn(BOARD, _spot); BOARD = gameTurn(BOARD, _spot);
} }
}); });
widget.boardUpdate(BOARD);
} }
@override @override
@@ -283,8 +300,14 @@ class _BoardSpotState extends State<BoardSpot> {
class PlayerSpot extends StatefulWidget { class PlayerSpot extends StatefulWidget {
final int spot; final int spot;
final List<int> board; final List<int> board;
final ValueChanged<List<int>> boardUpdate;
PlayerSpot({super.key, required this.board, required this.spot}); PlayerSpot({
super.key,
required this.board,
required this.spot,
required this.boardUpdate,
});
@override @override
State<PlayerSpot> createState() => _PlayerSpotState(); State<PlayerSpot> createState() => _PlayerSpotState();
@@ -306,7 +329,7 @@ class _PlayerSpotState extends State<PlayerSpot> {
h: 100, h: 100,
spot: _spot, spot: _spot,
board: widget.board, board: widget.board,
boardUpdate: null, boardUpdate: widget.boardUpdate,
); );
} }
} }