ChessboardController constructor

ChessboardController({
  1. MoveCallback? onMove,
  2. DrawCallback? onDraw,
  3. CheckCallback? onCheck,
  4. CheckMateCallback? onCheckMate,
  5. ResignCallback? onResign,
  6. OfferDrawCallback? onOfferDraw,
  7. 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();
}