create method

  1. @override
Future<String?> create({
  1. required String url,
  2. double? width,
  3. double? height,
  4. String? allow,
  5. String? sandbox,
  6. String? referrerPolicy,
  7. 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';
}