resize method

void resize(
  1. BuildContext context, {
  2. ScaleModeY? y,
  3. ScaleModeX? x,
  4. double? dx,
  5. double? dy,
})

Resizes the minimized view along x by dx and/or y by dy axis.

Implementation

void resize(
  BuildContext context, {
  ScaleModeY? y,
  ScaleModeX? x,
  double? dx,
  double? dy,
}) {
  switch (x) {
    case ScaleModeX.left:
      double w = _applyWidth(context, width.value - dx!);
      if (width.value - dx == w) {
        double l = _applyLeft(context, left.value + (width.value - w));
        if (left.value + (width.value - w) == l) {
          left.value = l;
          width.value = w;
        } else if (l == context.mediaQuerySize.width - width.value) {
          left.value = context.mediaQuerySize.width - w;
          width.value = w;
        }
      }
      break;

    case ScaleModeX.right:
      double w = _applyWidth(context, width.value - dx!);
      if (width.value - dx == w) {
        double r = left.value + w;
        if (r < context.mediaQuerySize.width) {
          width.value = w;
        }
      }
      break;

    default:
      break;
  }

  switch (y) {
    case ScaleModeY.top:
      double h = _applyHeight(context, height.value - dy!);
      if (height.value - dy == h) {
        double t = _applyTop(context, top.value + (height.value - h));
        if (top.value + (height.value - h) == t) {
          top.value = t;
          height.value = h;
        } else if (t == context.mediaQuerySize.height - height.value) {
          top.value = context.mediaQuerySize.height - h;
          height.value = h;
        }
      }
      break;

    case ScaleModeY.bottom:
      double h = _applyHeight(context, height.value - dy!);
      if (height.value - dy == h) {
        double b = top.value + h;
        if (b < context.mediaQuerySize.height) {
          height.value = h;
        }
      }
      break;

    default:
      break;
  }

  // Update the secondary constraints.
  applySecondaryConstraints();
}