renderThumbnail method
Implementation
Future<ImageElement?> renderThumbnail(
{String? renderedHTML,
bool includeDocumentStyles = true,
String? styles,
int? width = 800,
int? height = 600}) async {
renderedHTML ??= renderDomGenerator.generatedHTMLTrees.join('\n');
if (isEmptyObject(renderedHTML)) return null;
var svgStyles = '';
if (includeDocumentStyles) {
var rules = getAllCssStyleSheet()
.map((e) => e.rules)
.whereType<List<CssRule>>()
.expand((e) => e)
.toList();
svgStyles = rules.map((e) => e.cssText).join('\n');
}
if (isNotEmptyObject(styles)) {
svgStyles = '\n$styles';
}
var svg = htmlAsSvgContent(renderedHTML,
width: width, height: height, style: svgStyles);
var thumbnail = UISVG(parent,
svgContent: svg, width: '${width}px', height: '${height}px');
var renderedImage = await thumbnail.buildRenderedImage();
return renderedImage;
}