getWebContent static method
Implementation
static String getWebContent(String content, int targetWidthPx,
{String? fontSize,
String? backgroundColor,
String? lineHeight,
bool forceExpandImageWidget = false}) {
String contentFormatted;
try {
contentFormatted = Uri.decodeFull(content);
} catch (e) {
contentFormatted = content;
LogUtil.e(e);
}
var localFontSize = fontSize;
if (fontSize == null || fontSize.isEmpty) {
localFontSize = font_size;
}
String _webContentSuffix = webContentSuffix;
if (forceExpandImageWidget) {
_webContentSuffix =
"".replaceAll(r"<!--${EXPAND_IMG_WIDTH_JS}-->", expandImageSize);
}
var webContentPrefixFormatted = webContentPrefix.replaceAll(
KeyWebBackgroundColor, backgroundColor ?? "#ffffff");
return (webContentPrefixFormatted +
contentFormatted +
_webContentSuffix.replaceAll(KeyLineHeight, lineHeight ?? "1.8em"))
.replaceAll(
RegExp("font-size:[ ]*[0-9]*px"), "font-size:$localFontSize ")
.replaceAll(
RegExp("font-size:[ ]*[0-9]*pt"), "font-size:$localFontSize ")
.replaceAll(
RegExp("fontSize[ ]*=[ ]*'[0-9]*px'"), "fontSize='$localFontSize' ")
.replaceAll(RegExp("fontSize[ ]*=[ ]*'[0-9]*pt'"),
"fontSize='$localFontSize' ");
}