From 40d9f92d9a7df5b48dcda30b2d04c4805b7d255c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Niedz=CC=81wiecki?= Date: Sat, 8 Oct 2022 21:14:14 +0200 Subject: [PATCH] Fixed issue with size of piecess while being dragged --- lib/src/chess_board.dart | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/lib/src/chess_board.dart b/lib/src/chess_board.dart index a284eda..3f18e18 100644 --- a/lib/src/chess_board.dart +++ b/lib/src/chess_board.dart @@ -81,16 +81,25 @@ class _ChessBoardState extends State { ); var draggable = game.get(squareName) != null - ? Draggable( - child: piece, - feedback: piece, - childWhenDragging: SizedBox(), - data: PieceMoveData( - squareName: squareName, - pieceType: - pieceOnSquare?.type.toUpperCase() ?? 'P', - pieceColor: pieceOnSquare?.color ?? Color.WHITE, - ), + ? LayoutBuilder( + builder: (context, constraints) { + return Draggable( + child: piece, + feedback: SizedBox( + height: constraints.maxHeight, + width: constraints.maxWidth, + child: piece, + ), + childWhenDragging: const SizedBox(), + data: PieceMoveData( + squareName: squareName, + pieceType: + pieceOnSquare?.type.toUpperCase() ?? 'P', + pieceColor: + pieceOnSquare?.color ?? Color.WHITE, + ), + ); + }, ) : Container();