diff --git a/lib/src/widgets/board_thumbnail.dart b/lib/src/widgets/board_thumbnail.dart index 91f1629810..2095e4d797 100644 --- a/lib/src/widgets/board_thumbnail.dart +++ b/lib/src/widgets/board_thumbnail.dart @@ -15,6 +15,7 @@ class BoardThumbnail extends ConsumerStatefulWidget { this.footer, this.lastMove, this.onTap, + this.animationDuration, }); const BoardThumbnail.loading({ @@ -24,7 +25,8 @@ class BoardThumbnail extends ConsumerStatefulWidget { }) : orientation = Side.white, fen = kInitialFEN, lastMove = null, - onTap = null; + onTap = null, + animationDuration = null; /// Size of the board. final double size; @@ -46,6 +48,9 @@ class BoardThumbnail extends ConsumerStatefulWidget { final GestureTapCallback? onTap; + /// Optionally animate changes to the board by the specified duration. + final Duration? animationDuration; + @override _BoardThumbnailState createState() => _BoardThumbnailState(); } @@ -67,20 +72,32 @@ class _BoardThumbnailState extends ConsumerState { Widget build(BuildContext context) { final boardPrefs = ref.watch(boardPreferencesProvider); - final board = Chessboard.fixed( - size: widget.size, - fen: widget.fen, - orientation: widget.orientation, - lastMove: widget.lastMove as NormalMove?, - settings: ChessboardSettings( - enableCoordinates: false, - borderRadius: const BorderRadius.all(Radius.circular(4.0)), - boxShadow: boardShadows, - animationDuration: const Duration(milliseconds: 150), - pieceAssets: boardPrefs.pieceSet.assets, - colorScheme: boardPrefs.boardTheme.colors, - ), - ); + final board = widget.animationDuration != null + ? Chessboard.fixed( + size: widget.size, + fen: widget.fen, + orientation: widget.orientation, + lastMove: widget.lastMove as NormalMove?, + settings: ChessboardSettings( + enableCoordinates: false, + borderRadius: const BorderRadius.all(Radius.circular(4.0)), + boxShadow: boardShadows, + animationDuration: widget.animationDuration!, + pieceAssets: boardPrefs.pieceSet.assets, + colorScheme: boardPrefs.boardTheme.colors, + ), + ) + : StaticChessboard( + size: widget.size, + fen: widget.fen, + orientation: widget.orientation, + lastMove: widget.lastMove as NormalMove?, + enableCoordinates: false, + borderRadius: const BorderRadius.all(Radius.circular(4.0)), + boxShadow: boardShadows, + pieceAssets: boardPrefs.pieceSet.assets, + colorScheme: boardPrefs.boardTheme.colors, + ); final maybeTappableBoard = widget.onTap != null ? GestureDetector(