InteractiveViewer

InteractiveViewer 是 Flutter 1.20 新增的组件,用户可以通过拖动以平移、缩放和拖放子组件。

定义

  1. InteractiveViewer({
  2. Key key,
  3. this.alignPanAxis = false, //是否只在水平和垂直方向上拖拽,默认为false,设置为true,无法沿着对角线(斜着)方向移动。
  4. this.boundaryMargin = EdgeInsets.zero,
  5. this.constrained = true,
  6. // These default scale values were eyeballed as reasonable limits for common
  7. // use cases.
  8. this.maxScale = 2.5, //最大缩放倍数
  9. this.minScale = 0.8, //最小缩放倍数
  10. this.onInteractionEnd, //当用户在组件上结束平移或缩放手势时调用。
  11. this.onInteractionStart, //当用户开始平移或缩放手势时调用。
  12. this.onInteractionUpdate, //当用户更新组件上的平移或缩放手势时调用。
  13. this.panEnabled = true,
  14. this.scaleEnabled = true, //是否可以缩放
  15. this.transformationController,
  16. @required this.child,
  17. })

constrained 参数表示组件树中的约束是否应用于子组件,默认为true,如果设为true,表示子组件是无限制约束,这对子组件的尺寸比 InteractiveViewer 大时非常有用,比如子组件为滚动系列组件。