From bf72147b28182779946f0c1256f7ddaab61a2d5b Mon Sep 17 00:00:00 2001 From: Anton Eriksson Date: Wed, 17 Aug 2022 22:24:09 +0200 Subject: [PATCH] add a hint square --- lib/widgets/chessboard.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/widgets/chessboard.dart b/lib/widgets/chessboard.dart index 27caa01..0747ee3 100644 --- a/lib/widgets/chessboard.dart +++ b/lib/widgets/chessboard.dart @@ -14,6 +14,7 @@ import 'package:provider/provider.dart'; class Chessboard extends StatefulWidget { final Board board; + final String? hintSquare; Chessboard({ required String fen, @@ -26,10 +27,11 @@ class Chessboard extends StatefulWidget { BuildPiece? buildPiece, BuildSquare? buildSquare, BuildCustomPiece? buildCustomPiece, + String? hintSquare, Color lastMoveHighlightColor = const Color.fromRGBO(128, 128, 128, .3), Color selectionHighlightColor = const Color.fromRGBO(128, 128, 128, .3), List lastMove = const [], - }) : board = Board( + }) : board = Board( fen: fen, size: size, orientation: orientation, @@ -43,7 +45,8 @@ class Chessboard extends StatefulWidget { lastMove: lastMove, lastMoveHighlightColor: lastMoveHighlightColor, selectionHighlightColor: selectionHighlightColor, - ); + ), + hintSquare = hintSquare; @override State createState() => _ChessboardState(); @@ -76,6 +79,9 @@ class _ChessboardState extends State { } Color? _getHighlight(Square square) { + if (square.name == widget.hintSquare) { + return const Color.fromARGB(100, 80, 124, 101); + } return clickMove .filter((t) => t.square == square.name) .map((_) => widget.board.selectionHighlightColor)