ChessBoardInterface class
Use this as a main component for simulating chess with complete logics
- Available extensions
Constructors
- ChessBoardInterface({String? fen, Duration? timeLimit, dynamic onTimeOut()?})
Properties
-
blackTimeStream
→ Stream<
int> -
no setter
-
board
↔ List<
List< ChessPiece?> > -
getter/setter pair
- enPassantTarget ↔ Position?
-
En passant target Position (if any)
getter/setter pair
- fen → String?
-
final
- fullMoveNumber ↔ int
-
Fullmove number for draw conditions
getter/setter pair
- halfMoveClock ↔ int
-
Halfmove clock for draw conditions
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
-
history
↔ List<
String> -
Useful for generating PGN and other custom formats. Stores previous FEN states for operations like undo and more
getter/setter pair
- initialFENState ↔ String
-
Adjust the initial state FEN so that the first rank (board.
0) corresponds to the first row in the FEN and the last rank (board.7) corresponds to the last row. For example, if you want white pieces at the bottom (board.0), then your FEN might look like: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w'getter/setter pair - isDraw ↔ bool
-
Flag for draw by consent
getter/setter pair
- lastMoveFrom → Position?
-
Available on ChessBoardInterface, provided by the LastMoveGetter extension
Returns the Position from which a ChessPiece was moved, deduced by comparing the second last and last FEN strings.no setter - lastMoveTo → Position?
-
Available on ChessBoardInterface, provided by the LastMoveGetter extension
Returns the "to Position square" where a ChessPiece was moved, deduced by comparing the second last and last FEN strings.no setter - onTimeOut ↔ dynamic Function()?
-
getter/setter pair
-
redoHistory
↔ List<
String> -
Stores undone moves for redo
getter/setter pair
- resign ↔ PieceColor?
-
Register resignation. (Player who resigned)
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- timeLimit → Duration?
-
final
- turn ↔ PieceColor
-
getter/setter pair
-
whiteTimeStream
→ Stream<
int> -
countdown timers to listen times for both the players
no setter
Methods
-
canRedo(
) → bool -
Available on ChessBoardInterface, provided by the ChessBoardInterfaceExtension extension
Check if user can redo the last undone move. -
canUndo(
) → bool -
Available on ChessBoardInterface, provided by the ChessBoardInterfaceExtension extension
Check if user can undo the last move. -
deepCopy(
) → ChessBoardInterface -
Available on ChessBoardInterface, provided by the BoardUtils extension
Returns a deep copy of the current ChessBoardInterface instance. -
getCastlingRights(
) → String -
Available on ChessBoardInterface, provided by the ChessBoardInterfaceExtension extension
-
getPiece(
Position position) → ChessPiece? -
Available on ChessBoardInterface, provided by the ChessBoardInterfaceExtension extension
Get the piece at the specified position. -
getValidMoves(
Position from) → List< Position> -
Available on ChessBoardInterface, provided by the ChessBoardInterfaceExtension extension
Returns a list of valid moves for the selected piece, to render in the ChessBoardWidget. -
initFEN(
String fen) → void -
Available on ChessBoardInterface, provided by the BoardUtils extension
initializes the board with the given FEN string. -
isCheckmate(
) → bool -
Available on ChessBoardInterface, provided by the ChessBoardInterfaceExtension extension
Checks if the game is in a checkmate state. turn is the player loses the game -
isEligibleForPromotion(
Position position) → bool -
Available on ChessBoardInterface, provided by the ChessBoardInterfaceExtension extension
Checks if a piece is eligible for promotion. -
isFiftyMoveDraw(
) → bool -
Available on ChessBoardInterface, provided by the ChessBoardInterfaceExtension extension
Checks if the game is in a draw state due to the fifty-move rule. -
isInsufficientMaterial(
) → bool -
Available on ChessBoardInterface, provided by the ChessBoardInterfaceExtension extension
Checks if the game is in a draw state due to insufficient material. -
isKingInCheck(
) → bool -
Available on ChessBoardInterface, provided by the ChessBoardInterfaceExtension extension
Checks if the king is in check. -
isStalemate(
) → bool -
Available on ChessBoardInterface, provided by the ChessBoardInterfaceExtension extension
Checks if the game is in a stalemate state. -
isThreefoldRepetition(
) → bool -
Available on ChessBoardInterface, provided by the ChessBoardInterfaceExtension extension
Checks if the game is in a draw state due to threefold repetition. -
isTimeOut(
) → bool -
Available on ChessBoardInterface, provided by the ChessBoardInterfaceExtension extension
Checks if the game is in time out. turn is the player loses the game -
move(
Position from, Position to) → bool -
Available on ChessBoardInterface, provided by the ChessBoardInterfaceExtension extension
Move a piece from one position to another, with complete validations. -
movePiece(
Position from, Position to) → bool - Moves a piece on the board without validation.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
promotePawn(
Position position, PieceType type) → void -
Available on ChessBoardInterface, provided by the ChessBoardInterfaceExtension extension
Promotes PieceType.pawn to the specifiedtype. -
redo(
) → void -
Available on ChessBoardInterface, provided by the ChessBoardInterfaceExtension extension
Redo the last undone move and restore the forth state. -
reset(
) → void -
Available on ChessBoardInterface, provided by the BoardUtils extension
Resets the board to its initialFENState. -
setDraw(
bool draw) → void -
setResign(
PieceColor color) → void -
switchTimer(
{bool stop = false}) → void -
Available on ChessBoardInterface, provided by the BoardUtils extension
-
switchTurn(
) → void -
Available on ChessBoardInterface, provided by the ChessBoardInterfaceExtension extension
Switch turn to the opposite ChessPiece.color / player. -
toFEN(
) → String -
Available on ChessBoardInterface, provided by the BoardUtils extension
-
toString(
) → String -
A string representation of this object.
inherited
-
undo(
) → void -
Available on ChessBoardInterface, provided by the ChessBoardInterfaceExtension extension
Undo the last move and restore the previous state.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
getPieceChar(
ChessPiece piece) → String -
getPieceFromChar(
String char) → ChessPiece