layout method

  1. @override
void layout(
  1. double left,
  2. double top,
  3. double right,
  4. double bottom,
)
override

Implementation

@override
void layout(double left, double top, double right, double bottom) {
  if (layoutCompleted && !forceLayout) {
    bool b1 = (left - boundRect.left).abs() < 1;
    bool b2 = (top - boundRect.top).abs() < 1;
    bool b3 = (right - boundRect.right).abs() < 1;
    bool b4 = (bottom - boundRect.bottom).abs() < 1;
    if (b1 && b2 && b3 && b4) {
      return;
    }
  }

  inLayout = true;
  oldBoundRect = boundRect;
  boundRect = Rect.fromLTRB(left, top, right, bottom);

  if (parent == null) {
    _globalBoundRect = boundRect;
  } else {
    Rect parentRect = parent!.getGlobalAreaBounds();
    double l = parentRect.left + boundRect.left;
    double t = parentRect.top + boundRect.top;
    _globalBoundRect = Rect.fromLTWH(l, t, boundRect.width, boundRect.height);
  }
  onLayout(left, top, right, bottom);
  inLayout = false;
  forceLayout = false;
  layoutCompleted = true;
  onLayoutEnd();
}