extractEmbedHeight static method
Reads height: …px from wrapper styles, else defaultHeight.
Implementation
static double extractEmbedHeight(String embedHtml) {
final styleHeight = RegExp(
r'height:\s*(\d+(?:\.\d+)?)\s*px',
caseSensitive: false,
).firstMatch(embedHtml);
if (styleHeight != null) {
return double.parse(styleHeight.group(1)!);
}
final attrHeight = RegExp(
r'''height=["'](\d+(?:\.\d+)?)''',
caseSensitive: false,
).firstMatch(embedHtml);
if (attrHeight != null) {
return double.parse(attrHeight.group(1)!);
}
return defaultHeight;
}