Allow free zoom and pan in drawing mode
This commit is contained in:
@@ -96,19 +96,33 @@ class _DrawingBoardState extends State<DrawingBoard> {
|
||||
}
|
||||
|
||||
// Drawing mode: wrap with InteractiveViewer for zoom/pan
|
||||
return Align(
|
||||
alignment: widget.alignment,
|
||||
child: InteractiveViewer(
|
||||
// Use LayoutBuilder to get available size and center content manually
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
// Calculate padding to center the content
|
||||
final horizontalPadding =
|
||||
(constraints.maxWidth - widget.boardSize.width) / 2;
|
||||
final verticalPadding =
|
||||
(constraints.maxHeight - widget.boardSize.height) / 2;
|
||||
|
||||
return InteractiveViewer(
|
||||
transformationController: _transformationController,
|
||||
minScale: widget.minScale,
|
||||
maxScale: widget.maxScale,
|
||||
boundaryMargin: EdgeInsets.zero,
|
||||
constrained: true,
|
||||
boundaryMargin: const EdgeInsets.all(double.infinity),
|
||||
constrained: false,
|
||||
panEnabled: !_isDrawing,
|
||||
scaleEnabled: !_isDrawing,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: horizontalPadding > 0 ? horizontalPadding : 0,
|
||||
top: verticalPadding > 0 ? verticalPadding : 0,
|
||||
),
|
||||
child: content,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Builds the drawing layer with gesture handling.
|
||||
|
||||
Reference in New Issue
Block a user