我正在尝试在自定义画笔上绘制图像。 我正在使用Flutter CustomPainter视频中的示例,这是我目前的进展情况。我可以在图像中绘制,但是我无法缩放图像。如何在手势操作下缩放图像并在图像上绘制? 我宁愿不使用任何软件包。
Container(
height: double.infinity,
width: double.infinity,
color: Colors.black87,
child: FittedBox(
child: GestureDetector(
onScaleStart: _scaleStartGesture,
onScaleUpdate: _scaleUpdateGesture,
onScaleEnd: (_) => _scaleEndGesture(),
child: SizedBox(
height: _image.height.toDouble(),
width: _image.width.toDouble(),
child: CustomPaint(
willChange: true,
painter: ImagePainter(
image: _image,
points: points
),
),
),
),
),
),
InteractiveViewer
内部的源代码使用Transform
和GestureDetector
来实现缩放效果。如果您认为InteractiveViewer
中的缩放效果已经足够了,我建议您查看它是如何实现的。 - yellowgray