[英]Flutter CustomPainter Pan and Zoom
I have created a family tree widget via CustomPainter.我通过 CustomPainter 创建了一个家谱小部件。 How do I implement pan and zoom because parts of it overflowed.我如何实现平移和缩放,因为它的一部分溢出了。
I have tried GestureDetector and Translating the points via onPanUpdate but it is resetting to the current offset.我已经尝试过 GestureDetector 并通过 onPanUpdate 翻译点,但它正在重置为当前偏移量。
onPanUpdate: (d) {
RenderBox box = context.findRenderObject();
Offset point = box.globalToLocal(d.globalPosition);
point = point.translate(0.0, AppBar().preferredSize.height);
setState(() {
_offset = point;
});
// print(point);
},
// this is from CustomPainter
canvas.translate(offset.dx, offset.dy);
https://gist.github.com/klaszlo8207/0df97fb3ba7484e20b0061076f3be842 https://gist.github.com/klaszlo8207/0df97fb3ba7484e20b0061076f3be842
Here is my gist for this, this is a custom GestureDetector that can Scale and Pan这是我的要点,这是一个可以缩放和平移的自定义GestureDetector
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.