diff --git a/lib/main.dart b/lib/main.dart index 6d425b7..30fac1d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -60,7 +60,15 @@ class _GameBoardState extends State { 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 { ), // 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 board; final double w; final double h; - final ValueChanged>? boardUpdate; + final ValueChanged> boardUpdate; BoardSpot({ super.key, @@ -263,6 +279,7 @@ class _BoardSpotState extends State { BOARD = gameTurn(BOARD, _spot); } }); + widget.boardUpdate(BOARD); } @override @@ -283,8 +300,14 @@ class _BoardSpotState extends State { class PlayerSpot extends StatefulWidget { final int spot; final List board; + final ValueChanged> boardUpdate; - PlayerSpot({super.key, required this.board, required this.spot}); + PlayerSpot({ + super.key, + required this.board, + required this.spot, + required this.boardUpdate, + }); @override State createState() => _PlayerSpotState(); @@ -306,7 +329,7 @@ class _PlayerSpotState extends State { h: 100, spot: _spot, board: widget.board, - boardUpdate: null, + boardUpdate: widget.boardUpdate, ); } }