InteractiveViewer.builder constructor Null safety

InteractiveViewer.builder(
  1. {Key? key,
  2. Clip clipBehavior,
  3. bool alignPanAxis,
  4. EdgeInsets boundaryMargin,
  5. double maxScale,
  6. double minScale,
  7. GestureScaleEndCallback? onInteractionEnd,
  8. GestureScaleStartCallback? onInteractionStart,
  9. GestureScaleUpdateCallback? onInteractionUpdate,
  10. bool panEnabled,
  11. bool scaleEnabled,
  12. TransformationController? transformationController,
  13. 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.

The builder parameter must not be null. See its docs for an example of using it to optimize a large child.

Implementation

InteractiveViewer.builder({
  Key? key,
  this.clipBehavior = Clip.hardEdge,
  this.alignPanAxis = false,
  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.onInteractionEnd,
  this.onInteractionStart,
  this.onInteractionUpdate,
  this.panEnabled = true,
  this.scaleEnabled = true,
  this.transformationController,
  required InteractiveViewerWidgetBuilder this.builder,
}) : assert(alignPanAxis != null),
     assert(builder != null),
     assert(minScale != null),
     assert(minScale > 0),
     assert(minScale.isFinite),
     assert(maxScale != null),
     assert(maxScale > 0),
     assert(!maxScale.isNaN),
     assert(maxScale >= minScale),
     assert(panEnabled != null),
     assert(scaleEnabled != null),
     // 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,
     super(key: key);