11import 'dart:convert' ;
22import 'dart:math' ;
3+ import 'dart:ui_web' as ui_web;
34
45import 'package:flutter/material.dart' ;
56import 'package:flutter_html/flutter_html.dart' ;
6- import 'package:flutter_html_iframe/shims/dart_ui.dart' as ui;
7- // ignore: avoid_web_libraries_in_flutter
8- import 'dart:html' as html;
97
108import 'package:webview_flutter/webview_flutter.dart' ;
119
@@ -21,34 +19,38 @@ class IframeWidget extends StatelessWidget {
2119
2220 @override
2321 Widget build (BuildContext context) {
24- final givenWidth =
25- double .tryParse (extensionContext.attributes['width' ] ?? "" );
26- final givenHeight =
27- double .tryParse (extensionContext.attributes['height' ] ?? "" );
22+ final givenWidth = double .tryParse (
23+ extensionContext.attributes['width' ] ?? "" ,
24+ );
25+ final givenHeight = double .tryParse (
26+ extensionContext.attributes['height' ] ?? "" ,
27+ );
2828 final html.IFrameElement iframe = html.IFrameElement ()
2929 ..width = (givenWidth ?? (givenHeight ?? 150 ) * 2 ).toString ()
3030 ..height = (givenHeight ?? (givenWidth ?? 300 ) / 2 ).toString ()
3131 ..src = extensionContext.attributes['src' ]
3232 ..style.border = 'none' ;
3333 final String createdViewId = _getRandString (10 );
34- ui.platformViewRegistry
35- .registerViewFactory (createdViewId, (int viewId) => iframe);
34+ ui_web.platformViewRegistry.registerViewFactory (
35+ createdViewId,
36+ (int viewId) => iframe,
37+ );
3638 return SizedBox (
37- width: double .tryParse (extensionContext.attributes['width' ] ?? "" ) ??
39+ width:
40+ double .tryParse (extensionContext.attributes['width' ] ?? "" ) ??
3841 (double .tryParse (extensionContext.attributes['height' ] ?? "" ) ??
3942 150 ) *
4043 2 ,
41- height: double .tryParse (extensionContext.attributes['height' ] ?? "" ) ??
44+ height:
45+ double .tryParse (extensionContext.attributes['height' ] ?? "" ) ??
4246 (double .tryParse (extensionContext.attributes['width' ] ?? "" ) ?? 300 ) /
4347 2 ,
4448 child: CssBoxWidget (
4549 style: extensionContext.styledElement! .style,
4650 childIsReplaced: true ,
4751 child: Directionality (
4852 textDirection: extensionContext.styledElement! .style.direction! ,
49- child: HtmlElementView (
50- viewType: createdViewId,
51- ),
53+ child: HtmlElementView (viewType: createdViewId),
5254 ),
5355 ),
5456 );
0 commit comments