afterResize method

  1. @protected
void afterResize({
  1. bool forceUpdate = true,
})

Cal this method after resize

Implementation

@protected
void afterResize({bool forceUpdate = true}) {
  Matrix4 transform = transformationController!.value;
  Vector3 translation = transform.getTranslation();
  Rect boundaryRect = childBoundaryRect;
  Rect viewport = widgetViewport;

  double scale = transform.getScaleOnZAxis();

  double realWidth = boundaryRect.width * scale;
  double realHeight = boundaryRect.height * scale;

  double leftPositionX = translation.x;
  double topPositionY = translation.y;
  double rightPositionX = leftPositionX + realWidth;
  double bottomPositionY = topPositionY + realHeight;

  bool changed = false;
  if (realWidth > viewport.width) {
    if (leftPositionX < 0 && rightPositionX < viewport.width) {
      translation.x = viewport.width - realWidth;
      changed = true;
    }
  }

  if (realWidth < viewport.width && translation.x != 0.0) {
    translation.x = 0;
    changed = true;
  }

  if (realHeight > viewport.height) {
    if (topPositionY < 0 && bottomPositionY < viewport.height) {
      translation.y = viewport.height - realHeight;
      changed = true;
    }
  }

  if (realHeight < viewport.height && translation.y != 0.0) {
    translation.y = 0;
    changed = true;
  }

  if (changed) {
    transform = transform.clone()..setTranslation(translation);
    transformationController!.value = transform;
  } else if (forceUpdate) {
    updateTransform();
  }
}