parse method
Parses tree
for build ops and text styles.
Implementation
@override
void parse(BuildMetadata meta) {
switch (meta.element.localName) {
case kTagIframe:
meta.register(
_tagIframe ??= BuildOp(
// TODO: set debugLabel when our minimum core version >= 1.0
defaultStyles: (element) {
// other tags that share the same logic:
// - IMG
// - SVG
//
// consider update them together if this changes
final attrs = element.attributes;
final height = attrs[kAttributeIframeHeight];
final width = attrs[kAttributeIframeWidth];
return {
'height': 'auto',
'min-width': '0px',
'min-height': '0px',
'width': 'auto',
if (height != null && width != null) ...{
'height': '${height}px',
'width': '${width}px',
},
};
},
onWidgets: (meta, widgets) {
if (defaultTargetPlatform != TargetPlatform.android &&
defaultTargetPlatform != TargetPlatform.iOS &&
!kIsWeb) {
// Android & iOS are the webview_flutter's supported platforms
// Flutter web support is implemented by this package
// https://pub.dev/packages/webview_flutter/versions/2.0.12
return widgets;
}
final a = meta.element.attributes;
final src = urlFull(a[kAttributeIframeSrc] ?? '');
if (src == null) {
return widgets;
}
final height = tryParseDoubleFromMap(a, kAttributeIframeHeight);
final width = tryParseDoubleFromMap(a, kAttributeIframeWidth);
final sandbox = a[kAttributeIframeSandbox]?.split(RegExp(r'\s+'));
final built = buildWebView(
meta,
src,
height: height,
sandbox: sandbox,
width: width,
);
return listOrNull(built) ?? widgets;
},
),
);
}
return super.parse(meta);
}