draw static method

void draw(
  1. Widget widget, {
  2. PdfPage? page,
  3. PdfGraphics? canvas,
  4. BoxConstraints? constraints,
  5. required PdfPoint offset,
  6. Alignment? alignment,
  7. Context? context,
})

Draw a widget to a page canvas.

Implementation

static void draw(
  Widget widget, {
  PdfPage? page,
  PdfGraphics? canvas,
  BoxConstraints? constraints,
  required PdfPoint offset,
  Alignment? alignment,
  Context? context,
}) {
  context ??= Context(
    document: page!.pdfDocument,
    page: page,
    canvas: canvas!,
  ).inheritFromAll(<Inherited>[
    ThemeData.base(),
  ]);

  widget.layout(
    context,
    constraints ?? const BoxConstraints(),
  );

  assert(widget.box != null);

  if (alignment != null) {
    final d = alignment.withinRect(widget.box!);
    offset = PdfPoint(offset.x - d.x, offset.y - d.y);
  }

  widget.box = PdfRect.fromPoints(offset, widget.box!.size);

  widget.paint(context);
}