paint method

  1. @protected
void paint(
  1. Widget child,
  2. Context context
)

Implementation

@protected
void paint(Widget child, Context context) {
  final _margin = resolvedMargin!;
  final box = PdfRect(
    _margin.left,
    _margin.bottom,
    pageFormat.width - _margin.horizontal,
    pageFormat.height - _margin.vertical,
  );
  if (pageTheme.clip) {
    context.canvas
      ..saveContext()
      ..drawRect(box.left, box.bottom, box.width, box.height)
      ..clipPath();
  }

  if (pageTheme.textDirection == TextDirection.rtl) {
    child.box = PdfRect(
      ((mustRotate ? box.height : box.width) - child.box!.width) +
          child.box!.left,
      child.box!.bottom,
      child.box!.width,
      child.box!.height,
    );
  }

  if (mustRotate) {
    final _margin = resolvedMargin!;
    context.canvas
      ..saveContext()
      ..setTransform(
        Matrix4.identity()
          ..rotateZ(-math.pi / 2)
          ..translateByDouble(
            -pageFormat.height - _margin.left + _margin.top,
            -pageFormat.height +
                pageFormat.width +
                _margin.top -
                _margin.right,
            0,
            1,
          ),
      );
    child.paint(context);
    context.canvas.restoreContext();
  } else {
    child.paint(context);
  }

  if (pageTheme.clip) {
    context.canvas.restoreContext();
  }
}