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}) {
  box = PdfRect.fromPoints(PdfPoint.zero, constraints.biggest);
  if (child != null) {
    if (constraints.hasBoundedWidth && constraints.hasBoundedHeight) {
      final childConstraints = BoxConstraints(
        maxWidth: constraints.maxWidth - margin.horizontal,
        maxHeight: constraints.maxHeight - margin.vertical,
      );
      child!.layout(context, childConstraints, parentUsesSize: false);
    } else {
      child!.layout(context, constraints, parentUsesSize: false);
    }

    assert(child!.box != null);
    child!.box = PdfRect.fromPoints(
        PdfPoint(margin.left, box!.top - margin.top - child!.box!.height),
        child!.box!.size);
  }
}