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 {
9090 }
9191}
9292
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+
9398/// [IframeContentElement is a [ReplacedElement] with web content.
9499class IframeContentElement extends ReplacedElement {
95100 final String src;
@@ -110,11 +115,18 @@ class IframeContentElement extends ReplacedElement {
110115 @override
111116 Widget toWidget (RenderContext context) {
112117 final sandboxMode = attributes["sandbox" ];
118+ if (oldUrl != null && src != oldUrl && controller != null ) {
119+ controller.loadUrl (src);
120+ }
121+ oldUrl = src;
113122 return Container (
114123 width: width ?? (height ?? 150 ) * 2 ,
115124 height: height ?? (width ?? 300 ) / 2 ,
116125 child: WebView (
117126 initialUrl: src,
127+ onWebViewCreated: (WebViewController webController) {
128+ controller = webController;
129+ },
118130 javascriptMode: sandboxMode == null || sandboxMode == "allow-scripts"
119131 ? JavascriptMode .unrestricted
120132 : JavascriptMode .disabled,
You can’t perform that action at this time.
0 commit comments