refreshBoard method Null safety

void refreshBoard()

use refreshBoard to force controller callbacks to run, for example onMove, onCheck...

Implementation

void refreshBoard() {
  if (logic.inCheckmate && onCheckMate != null) {
    onCheckMate!(logic.turn == chessjs.WHITE ? chessjs.WHITE : chessjs.BLACK);
  } else if ((logic.inDraw ||
          logic.inStalemate ||
          logic.inThreefoldRepetition ||
          logic.insufficientMaterial) &&
      onDraw != null) {
    onDraw!();
  } else if (logic.inCheck && onCheck != null) {
    onCheck!(logic.turn == chessjs.WHITE ? chessjs.WHITE : chessjs.BLACK);
  } else {
    if (onMove != null) onMove!(logic.getHistoryVerbose().last);
  }
}