update_setup method

void update_setup(
  1. String fen
)

called when the initial board setup is changed with put() or remove(). modifies the SetUp and FEN properties of the header object. if the FEN is equal to the default position, the SetUp and FEN are deleted the setup is only updated if history.length is zero, ie moves haven't been made.

Implementation

void update_setup(String fen) {
  if (history.isNotEmpty) return;

  if (fen != DEFAULT_POSITION) {
    header['SetUp'] = '1';
    header['FEN'] = fen;
  } else {
    header.remove('SetUp');
    header.remove('FEN');
  }
}