InteractiveViewer.builder constructor

InteractiveViewer.builder({
  1. Key? key,
  2. Clip clipBehavior = Clip.hardEdge,
  3. PanAxis panAxis = PanAxis.free,
  4. EdgeInsets boundaryMargin = EdgeInsets.zero,
  5. double maxScale = 2.5,
  6. double minScale = 0.8,
  7. double interactionEndFrictionCoefficient = _kDrag,
  8. GestureScaleEndCallback? onInteractionEnd,
  9. GestureScaleStartCallback? onInteractionStart,
  10. GestureScaleUpdateCallback? onInteractionUpdate,
  11. bool panEnabled = true,
  12. bool scaleEnabled = true,
  13. double scaleFactor = 200.0,
  14. TransformationController? transformationController,
  15. Alignment? alignment,
  16. bool trackpadScrollCausesScale = false,
  17. required InteractiveViewerWidgetBuilder builder,
})

Creates an InteractiveViewer for a child that is created on demand.

Can be used to render a child that changes in response to the current transformation.

See the builder attribute docs for an example of using it to optimize a large child.

Implementation

InteractiveViewer.builder({
  super.key,
  this.clipBehavior = Clip.hardEdge,
  this.panAxis = PanAxis.free,
  this.boundaryMargin = EdgeInsets.zero,
  // These default scale values were eyeballed as reasonable limits for common
  // use cases.
  this.maxScale = 2.5,
  this.minScale = 0.8,
  this.interactionEndFrictionCoefficient = _kDrag,
  this.onInteractionEnd,
  this.onInteractionStart,
  this.onInteractionUpdate,
  this.panEnabled = true,
  this.scaleEnabled = true,
  this.scaleFactor = 200.0,
  this.transformationController,
  this.alignment,
  this.trackpadScrollCausesScale = false,
  required InteractiveViewerWidgetBuilder this.builder,
}) : assert(minScale > 0),
     assert(interactionEndFrictionCoefficient > 0),
     assert(minScale.isFinite),
     assert(maxScale > 0),
     assert(!maxScale.isNaN),
     assert(maxScale >= minScale),
     // boundaryMargin must be either fully infinite or fully finite, but not
     // a mix of both.
     assert(
       (boundaryMargin.horizontal.isInfinite && boundaryMargin.vertical.isInfinite) ||
           (boundaryMargin.top.isFinite &&
               boundaryMargin.right.isFinite &&
               boundaryMargin.bottom.isFinite &&
               boundaryMargin.left.isFinite),
     ),
     constrained = false,
     child = null;