Skip to content

Commit 2373c61

Browse files
authored
Merge pull request fluttercandies#63 from coder-with-a-bushido/karthi/fix-img-export
fix: getImageData outputs image with extra padding
2 parents 43d1a17 + 014e058 commit 2373c61

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

lib/src/drawing_board.dart

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -194,27 +194,27 @@ class _DrawingBoardState extends State<DrawingBoard> {
194194

195195
/// 构建画板
196196
Widget get _buildBoard {
197-
return RepaintBoundary(
198-
key: _controller.painterKey,
199-
child: ExValueBuilder<DrawConfig>(
200-
valueListenable: _controller.drawConfig,
201-
shouldRebuild: (DrawConfig p, DrawConfig n) =>
202-
p.angle != n.angle || p.size != n.size,
203-
builder: (_, DrawConfig dc, Widget? child) {
204-
Widget c = child!;
205-
206-
if (dc.size != null) {
207-
final bool isHorizontal = dc.angle.toDouble() % 2 == 0;
208-
final double max = dc.size!.longestSide;
209-
210-
if (!isHorizontal) {
211-
c = SizedBox(width: max, height: max, child: c);
212-
}
197+
return ExValueBuilder<DrawConfig>(
198+
valueListenable: _controller.drawConfig,
199+
shouldRebuild: (DrawConfig p, DrawConfig n) =>
200+
p.angle != n.angle || p.size != n.size,
201+
builder: (_, DrawConfig dc, Widget? child) {
202+
Widget c = child!;
203+
204+
if (dc.size != null) {
205+
final bool isHorizontal = dc.angle.toDouble() % 2 == 0;
206+
final double max = dc.size!.longestSide;
207+
208+
if (!isHorizontal) {
209+
c = SizedBox(width: max, height: max, child: c);
213210
}
211+
}
214212

215-
return Transform.rotate(angle: dc.angle * pi / 2, child: c);
216-
},
217-
child: Center(
213+
return Transform.rotate(angle: dc.angle * pi / 2, child: c);
214+
},
215+
child: Center(
216+
child: RepaintBoundary(
217+
key: _controller.painterKey,
218218
child: Stack(
219219
alignment: Alignment.center,
220220
children: <Widget>[_buildImage, _buildPainter],

0 commit comments

Comments
 (0)