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

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