generated from me/template-mit
Playing with the callback but still not having any luck.
This commit is contained in:
+28
-5
@@ -60,7 +60,15 @@ class _GameBoardState extends State<GameBoard> {
|
||||
children: [
|
||||
// Player 1 Goal
|
||||
Column(
|
||||
children: [Center(child: PlayerSpot(spot: 0, board: _BOARD))],
|
||||
children: [
|
||||
Center(
|
||||
child: PlayerSpot(
|
||||
spot: 0,
|
||||
board: _BOARD,
|
||||
boardUpdate: updateBoard,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// Center holes
|
||||
Column(
|
||||
@@ -210,7 +218,15 @@ class _GameBoardState extends State<GameBoard> {
|
||||
),
|
||||
// Player 2 Goal
|
||||
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 double w;
|
||||
final double h;
|
||||
final ValueChanged<List<int>>? boardUpdate;
|
||||
final ValueChanged<List<int>> boardUpdate;
|
||||
|
||||
BoardSpot({
|
||||
super.key,
|
||||
@@ -263,6 +279,7 @@ class _BoardSpotState extends State<BoardSpot> {
|
||||
BOARD = gameTurn(BOARD, _spot);
|
||||
}
|
||||
});
|
||||
widget.boardUpdate(BOARD);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -283,8 +300,14 @@ class _BoardSpotState extends State<BoardSpot> {
|
||||
class PlayerSpot extends StatefulWidget {
|
||||
final int spot;
|
||||
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
|
||||
State<PlayerSpot> createState() => _PlayerSpotState();
|
||||
@@ -306,7 +329,7 @@ class _PlayerSpotState extends State<PlayerSpot> {
|
||||
h: 100,
|
||||
spot: _spot,
|
||||
board: widget.board,
|
||||
boardUpdate: null,
|
||||
boardUpdate: widget.boardUpdate,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user