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
+
1
3
import 'package:flutter/foundation.dart' ;
2
4
import 'package:flutter/gestures.dart' ;
3
5
import 'package:flutter/material.dart' ;
@@ -34,17 +36,26 @@ class IframeWidget extends StatelessWidget {
34
36
final givenHeight =
35
37
double .tryParse (extensionContext.attributes['height' ] ?? "" );
36
38
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
+
37
51
return SizedBox (
38
52
width: givenWidth ?? (givenHeight ?? 150 ) * 2 ,
39
53
height: givenHeight ?? (givenWidth ?? 300 ) / 2 ,
40
54
child: CssBoxWidget (
41
55
style: extensionContext.styledElement! .style,
42
56
childIsReplaced: true ,
43
57
child: WebViewWidget (
44
- controller: controller
45
- ..loadRequest (
46
- Uri .tryParse (extensionContext.attributes['src' ] ?? "" ) ??
47
- Uri ()),
58
+ controller: controller..loadRequest (srcUri),
48
59
key: key,
49
60
gestureRecognizers: {Factory (() => VerticalDragGestureRecognizer ())},
50
61
),
You can’t perform that action at this time.
0 commit comments