BoardController constructor
BoardController({
- required PieceSet pieceSet,
- required BoardState state,
- required BoardTheme theme,
- BoardSize size = const BoardSize(8, 8),
- HighlightTheme? highlightTheme,
- dynamic onMove()?,
- dynamic onSetPremove(
- Move?
- dynamic onPremove()?,
- List<
Move> moves = const [], - required bool canMove,
- bool draggable = true,
- double dragFeedbackSize = 2.0,
- Offset dragFeedbackOffset = const Offset(0.0, -1.0),
- bool allowAnimation = true,
- Duration? animationDuration,
- Curve? animationCurve,
Implementation
BoardController({
required this.pieceSet,
required this.state,
required this.theme,
this.size = const BoardSize(8, 8),
this.highlightTheme,
this.onMove,
this.onSetPremove,
this.onPremove,
this.moves = const [],
required this.canMove,
this.draggable = true,
this.dragFeedbackSize = 2.0,
this.dragFeedbackOffset = const Offset(0.0, -1.0),
this.allowAnimation = true,
this.animationDuration,
this.animationCurve,
}) {
moveMap = {};
drops = [];
for (Move m in moves) {
if (m.handDrop) {
drops.add(m);
continue;
}
if (!moveMap.containsKey(m.from))
moveMap[m.from] = [m];
else
moveMap[m.from]!.add(m);
// Make pieces with no moves selectable
bool whitePlayer = state.player == WHITE;
for (int i = 0; i < state.board.length; i++) {
String p = state.board[i];
bool whitePiece = p == p.toUpperCase();
if (p.isNotEmpty && whitePlayer == whitePiece) {
if (!moveMap.containsKey(i)) moveMap[i] = [];
}
}
}
}