Allow free zoom and pan in drawing mode
This commit is contained in:
@@ -96,18 +96,32 @@ class _DrawingBoardState extends State<DrawingBoard> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Drawing mode: wrap with InteractiveViewer for zoom/pan
|
// Drawing mode: wrap with InteractiveViewer for zoom/pan
|
||||||
return Align(
|
// Use LayoutBuilder to get available size and center content manually
|
||||||
alignment: widget.alignment,
|
return LayoutBuilder(
|
||||||
child: InteractiveViewer(
|
builder: (context, constraints) {
|
||||||
transformationController: _transformationController,
|
// Calculate padding to center the content
|
||||||
minScale: widget.minScale,
|
final horizontalPadding =
|
||||||
maxScale: widget.maxScale,
|
(constraints.maxWidth - widget.boardSize.width) / 2;
|
||||||
boundaryMargin: EdgeInsets.zero,
|
final verticalPadding =
|
||||||
constrained: true,
|
(constraints.maxHeight - widget.boardSize.height) / 2;
|
||||||
panEnabled: !_isDrawing,
|
|
||||||
scaleEnabled: !_isDrawing,
|
return InteractiveViewer(
|
||||||
child: content,
|
transformationController: _transformationController,
|
||||||
),
|
minScale: widget.minScale,
|
||||||
|
maxScale: widget.maxScale,
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user