首页 > 解决方案 > 如何在颤动的交互式查看器中获得平移值?

问题描述

我正在制作一个画家,当我检测到我想在交互式查看器中以缩放模式绘制的点时,它会得到错误的偏移量,所以我需要在 x 坐标和 y 坐标中平移以获得正确的偏移量

标签: flutter

解决方案


使用 GestureDetector onPanUpdate方法获取手指滑动和当前手指坐标的变化

onPanUpdate: (pan){
print('Change In X:${pan.delta.dx}');
print('Change In Y:${pan.delta.dy}');
print('Global X Coordinate:${pan.globalPosition.dx}');
print('Global Y Coordinate:${pan.globalPosition.dy}');
print('Local x Coordinate:${pan.localPosition.dx}');
print('Local Y Coordinate:${pan.localPosition.dy}');}

推荐阅读