build method
Implementation
@override
pw.Widget build(pw.Context context) {
final theme = pw.Theme.of(context);
var effectiveMargin = margin;
var effectiveStyle = textStyle;
switch (level) {
case 0:
effectiveMargin ??= const pw.EdgeInsets.only(
bottom: 5.0 * PdfPageFormat.mm,
top: 10.0 * PdfPageFormat.mm,
);
effectiveStyle ??= theme.header0;
case 1:
effectiveMargin ??= const pw.EdgeInsets.only(
bottom: 5.0 * PdfPageFormat.mm,
top: 10.0 * PdfPageFormat.mm,
);
effectiveStyle ??= theme.header1;
case 2:
effectiveMargin ??= const pw.EdgeInsets.only(
bottom: 4.0 * PdfPageFormat.mm,
top: 8.0 * PdfPageFormat.mm,
);
effectiveStyle ??= theme.header2;
case 3:
effectiveMargin ??= const pw.EdgeInsets.only(
bottom: 4.0 * PdfPageFormat.mm,
top: 6.0 * PdfPageFormat.mm,
);
effectiveStyle ??= theme.header3;
case 4:
effectiveMargin ??= const pw.EdgeInsets.only(
top: 2.0 * PdfPageFormat.mm,
bottom: 4.0 * PdfPageFormat.mm,
);
effectiveStyle ??= theme.header4;
case 5:
effectiveMargin ??= const pw.EdgeInsets.only(
top: 2.0 * PdfPageFormat.mm,
bottom: 4.0 * PdfPageFormat.mm,
);
effectiveStyle ??= theme.header5;
}
final container = pw.Container(
alignment: pw.Alignment.topLeft,
margin: effectiveMargin,
padding: padding,
decoration: decoration,
child: child ?? BanglaAwareText(text!, style: effectiveStyle),
);
if (title == null) return container;
return pw.Outline(
name: text.hashCode.toString(),
title: title!,
level: level,
color: outlineColor,
style: outlineStyle,
child: container,
);
}