create method
Future<String?>
create({
- required String url,
- double? width,
- double? height,
- String? allow,
- String? sandbox,
- String? referrerPolicy,
- String? loading,
override
Creates an iframe with the specified URL and properties.
Implementation
@override
Future<String?> create({
required String url,
double? width,
double? height,
String? allow,
String? sandbox,
String? referrerPolicy,
String? loading,
}) async {
_iframeElement = html.IFrameElement()
..src = url
..style.border = 'none'
..allowFullscreen = true;
if (width != null) {
_iframeElement!.style.width = '${width}px';
}
if (height != null) {
_iframeElement!.style.height = '${height}px';
}
if (allow != null) {
_iframeElement!.allow = allow;
}
if (sandbox != null) {
_iframeElement!.setAttribute('sandbox', sandbox);
}
if (referrerPolicy != null) {
_iframeElement!.referrerPolicy = referrerPolicy;
}
if (loading != null) {
_iframeElement!.setAttribute('loading', loading);
}
// Add the iframe to the document body temporarily
html.document.body!.append(_iframeElement!);
return 'Iframe created successfully';
}