简体   繁体   English

Flutter InteractiveViewer 将缩放限制为一维

[英]Flutter InteractiveViewer restrict scaling to one dimension

How could I make scaling only possible on one dimension, eg the y dimension and have eg the x dimension fixed.我怎样才能使缩放只在一个维度上成为可能,例如 y 维度并固定 x 维度。 I am trying to make a (vertical) ruler, the user can scale (zoom) and the values of the ruler will change.我正在尝试制作(垂直)标尺,用户可以缩放(缩放)并且标尺的值会改变。 But the widths of the ruler lines should remain fixed.但是标尺线的宽度应该保持固定。 thx谢谢

I have found the following way.我找到了以下方法。 Not sure if there is a better way:不知道有没有更好的方法:

onInteractionUpdate: (details) {
      final M = _transformationController.value;
      V.Vector3 translation = V.Vector3.zero();
      V.Quaternion rotation = V.Quaternion.identity();
      V.Vector3 scale = V.Vector3.zero();
      M.decompose(translation, rotation, scale);
      _transformationController.value.scale(1 / scale.x, 1, 1 / scale.z);
    },

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM