InteractiveViewer
InteractiveViewer 是 Flutter 1.20 新增的组件,用户可以通过拖动以平移、缩放和拖放子组件。
定义
InteractiveViewer({
Key key,
this.alignPanAxis = false, //是否只在水平和垂直方向上拖拽,默认为false,设置为true,无法沿着对角线(斜着)方向移动。
this.boundaryMargin = EdgeInsets.zero,
this.constrained = true,
// These default scale values were eyeballed as reasonable limits for common
// use cases.
this.maxScale = 2.5, //最大缩放倍数
this.minScale = 0.8, //最小缩放倍数
this.onInteractionEnd, //当用户在组件上结束平移或缩放手势时调用。
this.onInteractionStart, //当用户开始平移或缩放手势时调用。
this.onInteractionUpdate, //当用户更新组件上的平移或缩放手势时调用。
this.panEnabled = true,
this.scaleEnabled = true, //是否可以缩放
this.transformationController,
@required this.child,
})
constrained 参数表示组件树中的约束是否应用于子组件,默认为true,如果设为true,表示子组件是无限制约束,这对子组件的尺寸比 InteractiveViewer 大时非常有用,比如子组件为滚动系列组件。