flutter - 如何在颤动的交互式查看器中获得平移值?
问题描述
我正在制作一个画家,当我检测到我想在交互式查看器中以缩放模式绘制的点时,它会得到错误的偏移量,所以我需要在 x 坐标和 y 坐标中平移以获得正确的偏移量
解决方案
使用 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}');}
推荐阅读
- c# - 如何在 ASP.NET MVC 中根据条件打开/关闭基于身份的身份验证
- sql - SQL - 添加列
- php - 简单的 if 语句返回意外值
- php - 有什么方法可以绕过 Defined("App") 或退出("no access")
- javascript - 单击按钮后,将事件侦听器添加到窗口
- python - 无法从类中正确获取列表数据
- tcl - 无法使用 exit 命令终止 TCL 脚本,因为它未被识别
- javascript - 如何使用 GitHub Actions 在我的项目中的特定目录中运行 ESLint
- here-api - 反向地理编码端点响应:“访问”字段
- php - 使用印度电话的正则表达式模式验证 woocommerce 结帐页面表单,用于 wordpress 中的模式 +91-1234567890 号码