layout method

  1. @override
void layout(
  1. Context context,
  2. BoxConstraints constraints, {
  3. bool parentUsesSize = false,
})
override

First widget pass to calculate the children layout and bounding box

Implementation

@override
void layout(Context context, BoxConstraints constraints,
    {bool parentUsesSize = false}) {
  if (width == null || height == null) {
    // Compute the bounding box
    _boundingBox = PdfGraphics.shapeBoundingBox(shape);
  } else {
    _boundingBox = PdfRect(0, 0, width!, height!);
  }

  final w = constraints.hasBoundedWidth
      ? constraints.maxWidth
      : constraints.constrainWidth(_boundingBox.width);
  final h = constraints.hasBoundedHeight
      ? constraints.maxHeight
      : constraints.constrainHeight(_boundingBox.height);

  final sizes = applyBoxFit(fit, _boundingBox.size, PdfPoint(w, h));
  box = PdfRect.fromPoints(
    PdfPoint.zero,
    sizes.destination!,
  );
}