writeShading function
void
writeShading(})
Writes a w:shd (shading/background) element if a fill or theme fill is set.
Shared by DocxText, DocxParagraph and DocxTableCell so background shading is serialized identically everywhere it appears, instead of each class re-implementing (and potentially forgetting part of) the same XML.
Implementation
void writeShading(
XmlBuilder builder, {
String? fill,
String? themeFill,
String? themeFillTint,
String? themeFillShade,
}) {
if (fill == null && themeFill == null) return;
builder.element('w:shd', nest: () {
builder.attribute('w:val', 'clear');
builder.attribute('w:color', 'auto');
builder.attribute('w:fill', fill?.replaceAll('#', '') ?? 'auto');
if (themeFill != null) builder.attribute('w:themeFill', themeFill);
if (themeFillTint != null) {
builder.attribute('w:themeFillTint', themeFillTint);
}
if (themeFillShade != null) {
builder.attribute('w:themeFillShade', themeFillShade);
}
});
}