File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,11 @@ class ImageContentElement extends ReplacedElement {
90
90
}
91
91
}
92
92
93
+ /// Create a webview controller and old src independent of [IframeContentElement]
94
+ /// to make sure it doesn't reset when the html string is updated
95
+ WebViewController controller;
96
+ String oldUrl;
97
+
93
98
/// [IframeContentElement is a [ReplacedElement] with web content.
94
99
class IframeContentElement extends ReplacedElement {
95
100
final String src;
@@ -110,11 +115,18 @@ class IframeContentElement extends ReplacedElement {
110
115
@override
111
116
Widget toWidget (RenderContext context) {
112
117
final sandboxMode = attributes["sandbox" ];
118
+ if (oldUrl != null && src != oldUrl && controller != null ) {
119
+ controller.loadUrl (src);
120
+ }
121
+ oldUrl = src;
113
122
return Container (
114
123
width: width ?? (height ?? 150 ) * 2 ,
115
124
height: height ?? (width ?? 300 ) / 2 ,
116
125
child: WebView (
117
126
initialUrl: src,
127
+ onWebViewCreated: (WebViewController webController) {
128
+ controller = webController;
129
+ },
118
130
javascriptMode: sandboxMode == null || sandboxMode == "allow-scripts"
119
131
? JavascriptMode .unrestricted
120
132
: JavascriptMode .disabled,
You can’t perform that action at this time.
0 commit comments