ChessboardController constructor
ChessboardController({
- MoveCallback? onMove,
- DrawCallback? onDraw,
- CheckCallback? onCheck,
- CheckMateCallback? onCheckMate,
- ResignCallback? onResign,
- OfferDrawCallback? onOfferDraw,
- String? startingPosition,
Implementation
ChessboardController({
this.onMove,
this.onDraw,
this.onCheck,
this.onCheckMate,
this.onResign,
this.onOfferDraw,
String? startingPosition,
}) {
_logic = chessjs.Chess();
if (startingPosition != null) {
final validateFen = chessjs.Chess.validateFen(startingPosition);
if (validateFen['valid'] == true) {
_logic.load(startingPosition);
} else {
assert(validateFen['valid'] != true,
'[Error] fen is not valid: ${validateFen['error']}');
}
}
buildBoard();
}