buildChessBoard method
Builds the board, drawing each square
Implementation
Widget buildChessBoard() {
final pieceSize = size / 8;
return NotificationListener<MoveNotification>(
onNotification: (moveNotifier) {
controller.makePrettyMove(moveNotifier.move);
return true;
},
child: ValueListenableBuilder<bool>(
valueListenable: whiteTowardUser,
builder: (context, value, child) {
print('value: $value');
return Column(children: [
if (value)
for (final row in squareList)
Expanded(
flex: 1,
child: Row(
children: row.map((squareName) {
return SquareUI(
key: ValueKey(squareName),
squareNotifier:
controller.getSquareNotifier(squareName),
squareName: squareName,
size: pieceSize,
controller: controller,
onMove: (move) {
playLocal();
},
);
}).toList(),
),
)
else
for (final row in squareList.reversed)
Expanded(
flex: 1,
child: Row(
children: row.reversed
.map((squareName) => SquareUI(
key: ValueKey(squareName),
squareNotifier:
controller.getSquareNotifier(squareName),
squareName: squareName,
size: pieceSize,
controller: controller,
onMove: (move) {
playLocal();
},
))
.toList(),
),
)
]);
}),
);
}