File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
packages/flutter_html_iframe/lib Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change 1+ import 'dart:convert' ;
2+
13import 'package:flutter/foundation.dart' ;
24import 'package:flutter/gestures.dart' ;
35import 'package:flutter/material.dart' ;
@@ -34,17 +36,26 @@ class IframeWidget extends StatelessWidget {
3436 final givenHeight =
3537 double .tryParse (extensionContext.attributes['height' ] ?? "" );
3638
39+ Uri ? srcUri;
40+
41+ if (extensionContext.attributes['srcdoc' ] != null ) {
42+ srcUri = Uri .dataFromString (
43+ extensionContext.attributes['srcdoc' ] ?? '' ,
44+ mimeType: 'text/html' ,
45+ encoding: Encoding .getByName ('utf-8' ),
46+ );
47+ } else {
48+ srcUri = Uri .tryParse (extensionContext.attributes['src' ] ?? "" ) ?? Uri ();
49+ }
50+
3751 return SizedBox (
3852 width: givenWidth ?? (givenHeight ?? 150 ) * 2 ,
3953 height: givenHeight ?? (givenWidth ?? 300 ) / 2 ,
4054 child: CssBoxWidget (
4155 style: extensionContext.styledElement! .style,
4256 childIsReplaced: true ,
4357 child: WebViewWidget (
44- controller: controller
45- ..loadRequest (
46- Uri .tryParse (extensionContext.attributes['src' ] ?? "" ) ??
47- Uri ()),
58+ controller: controller..loadRequest (srcUri),
4859 key: key,
4960 gestureRecognizers: {Factory (() => VerticalDragGestureRecognizer ())},
5061 ),
You can’t perform that action at this time.
0 commit comments