pdf_widgets library

Flutter-like PDF widgets. Pure Dart — no dart:ui.

import 'package:quds_office_engine/pdf_widgets.dart' as pw;

final doc = pw.Document(title: 'Invoice');
doc.addPage(
  pw.MultiPage(
    pageFormat: pw.PdfPageFormat.a4,
    build: (context) => <pw.Widget>[
      pw.Header(level: 1, text: 'Invoice'),
      pw.Paragraph(text: 'Payable on receipt.'),
    ],
  ),
);
final bytes = doc.save();

The writer types (PdfDocument, PdfPage, PdfCanvas) stay separate. Subclass Widget and implement Widget.layout for custom boxes.

Classes

Align
Same constructor as Flutter Align.
Alignment
Flutter alignment: x/y in -1..1 (top-left is -1,-1).
AlignmentDirectional
Alignment that flips with TextDirection. start is -1 at the start edge.
AlignmentGeometry
Physical or start/end alignment. Resolve before Alignment.alongOffset.
Anchor
Bookmark on the first produced box.
AspectRatio
Same constructor as Flutter AspectRatio.
Baseline
Shifts child so its baseline sits baseline points from the top.
Border
Box border.
BorderSide
One side of a border.
BoxConstraints
Flutter-style box constraints.
BoxDecoration
Box decoration (fill + stroke).
Builder
Rebuilds builder at layout time.
Bullet
Bullet / numbered list of widgets.
Center
Same constructor as Flutter Center.
Chart
Vector chart (no Flutter). Bars, line, and pie with axes, values, and legend.
ChartPoint
Class ChartPoint.
Checkbox
Checkbox mark (drawn; not an AcroForm field).
Circle
Filled / stroked oval.
ClipOval
Clips child to the oval inscribed in its box.
ClipPath
Clips child to clipper.
ClipRect
Clips child to its layout rectangle.
ClipRRect
Clips child to a rounded rectangle.
Column
Vertical flex.
ConstrainedBox
Same constructor as Flutter ConstrainedBox.
Container
Color + padding + alignment + constraints.
Context
Layout / paint environment. Flutter-like, no dart:ui.
CustomMultiChildLayout
Arranges LayoutId children by a function, not a fixed flex rule.
CustomPaint
Custom paint. size is used only when child is null.
DecoratedBox
Same constructor as Flutter DecoratedBox.
DefaultTextStyle
Merges style into the theme for child.
Directionality
Overrides reading direction.
Divider
Horizontal rule.
Document
Widget-tree PDF writer. Emits a native PdfDocument — does not rename it.
EdgeInsets
Insets around a child.
EdgeInsetsDirectional
Insets that flip with TextDirection. start is left in LTR, right in RTL.
EdgeInsetsGeometry
Physical or start/end insets. Resolve with resolve before painting.
EmptyBox
Empty box.
Expanded
Same constructor as Flutter Expanded.
FittedBox
Scales child to fit the incoming box.
FixedColumnWidth
Fixed point width.
Flex
Row or column from direction.
FlexColumnWidth
Flex share of remaining width after fixed columns.
Flexible
Flex child of Row / Column.
Page footer row: leading · title · trailing.
FractionallySizedBox
Sizes itself to a fraction of the incoming max constraint.
FractionColumnWidth
Fraction of the table's max width.
GridView
Fixed-count grid.
GroupBox
Multi-child box with absolute child origins (relative to this box).
Heading 0–5. Registers a TOC / outline entry.
Icon
One glyph from the document face, centered in a square of size.
Image
Inline picture.
ImageProvider
Image bytes provider.
InlineSpan
Inline node inside RichText.
Inseparable
Keep-together hint. MultiPage already avoids splitting a single box.
IntrinsicColumnWidth
Size to the child's intrinsic width; optional flex for leftover space.
IntrinsicHeight
Second pass gives child a tight height equal to its loose height.
LayoutId
Tags a child so CustomMultiChildLayout can lay it out by id.
LimitedBox
Caps an unbounded axis. A bounded axis is left alone.
LinearGradient
Axis-aligned color blend (painted as strips — no PDF shading object).
Tappable URI or internal destination over child.
ListTile
Leading, title, subtitle, and trailing. Slots, not a document.
ListView
Non-scrolling column (PDF has no viewport). Same children as Flutter ListView.
Lorem
Same role as pw.Lorem.
LoremText
Deterministic lorem words.
MemoryImage
In-memory PNG / JPEG.
MultiChildLayoutHost
Host passed to CustomMultiChildLayout.performLayout.
MultiPage
Flowing multi-page section.
NewPage
Forced page break inside MultiPage.
Opacity
Documented opacity. The writer has no ExtGState yet, so the child paints as-is.
OverflowBox
Lets child ignore the incoming max and paint outside this box.
Padding
Same constructor as Flutter Padding.
Page
One laid-out PDF page (widget API — not PdfPage).
PageTheme
Page chrome: format, margin, direction, theme.
Paragraph
Body paragraph with bottom margin.
PdfPageFormat
Page size in typographic points.
Placeholder
Empty bordered box.
Positioned
Absolutely positioned Stack child.
ProxyBox
Parent that paints a decoration then a child.
PwBox
Measured widget. Users subclass Widget and return a PwBox.
PwClosePath
close API.
PwHeading
Heading recorded for TOC / PDF outlines.
PwLineTo
lineTo API.
PwMoveTo
moveTo API.
PwOffset
Top-left offset in page space.
PwPath
Path the caller fills in local coordinates. ClipPath clips to it.
PwPathOp
One recorded path command, in the child's local space.
PwSize
2D size in typographic points.
Radio
Drawn radio mark. Not an AcroForm field.
Rectangle
Filled / stroked rectangle.
RichText
Rich paragraph of TextSpan / WidgetSpan children.
RotatedBox
Quarter-turn rotation that swaps width and height when the turn is odd.
Row
Horizontal flex.
SizedBox
Same constructors as Flutter SizedBox.
Spacer
Same constructor as Flutter Spacer.
SpanSlice
One page-slice of a widget that can flow across MultiPage.
Stack
Stack of children. Positioned pins a child.
Switch
Drawn switch. The thumb sits at the start edge when off.
Table
Grid table with optional borders and flex column widths.
TableBorder
Interior + exterior borders for a Table (package:pdf TableBorder).
TableCell
Table cell wrapping a child widget.
TableColumnWidth
Column sizing strategy (package:pdf TableColumnWidth).
TableOfContent
Two-pass TOC from Header entries.
TableRow
Table row. Same role as Flutter / package:pdf TableRow.
Text
Single-run wrapped text.
TextDecoration
Same names as Flutter / package:pdf TextDecoration.
TextField
Underlined value (form-like, not an AcroForm field).
TextSpan
Text run. Same constructor as Flutter / package:pdf TextSpan.
TextStyle
Run style. Measured and painted by the PDF layout engine.
Theme
Overrides ThemeData for child.
ThemeData
Inherited text + heading styles for a Document.
Transform
Rotates, scales, or shifts child at paint time. Layout size is unchanged.
URI annotation over child.
VerticalDivider
Vertical rule. width is the slot; the stroke sits in the middle.
Watermark
Diagonal document stamp, extracted by MultiPage.
Widget
Constraint-layout widget. Subclass and implement layout (like RenderBox).
WidgetSpan
Embedded child inside RichText.
Wrap
Flow children onto the next line when they overflow.

Enums

Axis
Main-axis direction.
BoxFit
Image fit.
BoxShape
Decoration shape.
ChartType
Chart kind drawn with PdfCanvas paths.
CrossAxisAlignment
Cross-axis alignment for Row / Column.
FlexFit
How a flex child is sized.
FontStyle
Font style.
FontWeight
Font weight.
MainAxisAlignment
How children sit on a Row / Column.
MainAxisSize
How much space a Flex should occupy on its main axis.
PageOrientation
Page rotation hint.
StackFit
How a Stack sizes itself.
TableCellVerticalAlignment
How a cell sits inside its row height (package:pdf TableCellVerticalAlignment).
TextAlign
How text is aligned.
TextDirection
Reading direction.
TextOverflow
How Text treats a line that does not fit Text.maxLines.
WrapAlignment
How a Wrap run is packed.

Mixins

PwPageOverlay
Overlay drawn on every MultiPage sheet (watermark).

Typedefs

BuildCallback = Widget Function(Context context)
Builds a single child from the current Context.
BuildListCallback = List<Widget> Function(Context context)
Builds a flowing list of children (used by MultiPage).
PageFormat = PdfPageFormat
Alias used in some samples.
PdfCustomPainter = void Function(PdfCanvas canvas, PwSize size)
Draws behind and in front of child. Coordinates are local to the box.
PwClipper = void Function(PwPath path, PwSize size)
Builds the clip path in the child's local coordinates.
WidgetBuilder = Widget Function(Context context)
Rebuilds a subtree.