Fix green flicker of squares on invalid move
This commit is contained in:
parent
b9d574f2ab
commit
f45ec47285
@ -22,8 +22,9 @@ class ChessBoard extends StatelessWidget {
|
|||||||
final piece = boardState.position[ChessCoordinate(column, row)];
|
final piece = boardState.position[ChessCoordinate(column, row)];
|
||||||
|
|
||||||
bool squareWasPartOfLastMove = false;
|
bool squareWasPartOfLastMove = false;
|
||||||
if (boardState.lastMove.to == ChessCoordinate(column, row) ||
|
if ((boardState.lastMove.to == ChessCoordinate(column, row) ||
|
||||||
boardState.lastMove.from == ChessCoordinate(column, row)) {
|
boardState.lastMove.from == ChessCoordinate(column, row)) &&
|
||||||
|
boardState.positionAckd) {
|
||||||
squareWasPartOfLastMove = true;
|
squareWasPartOfLastMove = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ class ChessBloc extends Bloc<ChessEvent, ChessBoardState> {
|
|||||||
ChessColor.white,
|
ChessColor.white,
|
||||||
ChessPositionManager.getInstance().currentPosition,
|
ChessPositionManager.getInstance().currentPosition,
|
||||||
ChessMove.none(),
|
ChessMove.none(),
|
||||||
|
false,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -56,6 +57,7 @@ class ChessBloc extends Bloc<ChessEvent, ChessBoardState> {
|
|||||||
state.newTurnColor,
|
state.newTurnColor,
|
||||||
state.position,
|
state.position,
|
||||||
ChessMove.none(),
|
ChessMove.none(),
|
||||||
|
false,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -76,6 +78,7 @@ class ChessBloc extends Bloc<ChessEvent, ChessBoardState> {
|
|||||||
turnColor,
|
turnColor,
|
||||||
event.position,
|
event.position,
|
||||||
ChessMove(from: event.startSquare, to: event.endSquare),
|
ChessMove(from: event.startSquare, to: event.endSquare),
|
||||||
|
true,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||