@@ -83,6 +83,8 @@ class PassiveWebViewWidget extends StatefulWidget {
83
83
class _PassiveWebViewWidgetState extends State <PassiveWebViewWidget > {
84
84
late WebViewController _controller;
85
85
86
+ bool _isDataLoaded = false ;
87
+
86
88
@override
87
89
void initState () {
88
90
super .initState ();
@@ -134,26 +136,28 @@ class _PassiveWebViewWidgetState extends State<PassiveWebViewWidget> {
134
136
_controller.setBackgroundColor (
135
137
props.backgroundColor? .toFlutterColor () ?? Colors .transparent);
136
138
}
137
-
138
- _loadData ();
139
139
}
140
140
141
141
void _loadData () {
142
142
final props = widget.node.properties;
143
143
switch (props.webviewType) {
144
144
case WebViewType .webpage:
145
145
final properties = props as WebPageWebViewProperties ;
146
+ final String input =
147
+ PropertyValueDelegate .getVariableValueFromPath <String >(
148
+ context, properties.input) ??
149
+ properties.input;
146
150
switch (properties.pageSourceType) {
147
151
case WebViewWebpageSourceType .url:
148
- _controller.loadRequest (Uri .parse (properties. input));
152
+ _controller.loadRequest (Uri .parse (input));
149
153
break ;
150
154
case WebViewWebpageSourceType .html:
151
- final content = _buildHtmlContent (properties. input);
155
+ final content = _buildHtmlContent (input);
152
156
_controller.loadRequest (Uri .parse (content));
153
157
break ;
154
158
case WebViewWebpageSourceType .asset:
155
159
// provided from onWebViewCreated callback.
156
- _controller.loadFlutterAsset (properties. input);
160
+ _controller.loadFlutterAsset (input);
157
161
break ;
158
162
}
159
163
break ;
@@ -169,6 +173,15 @@ class _PassiveWebViewWidgetState extends State<PassiveWebViewWidget> {
169
173
}
170
174
}
171
175
176
+ @override
177
+ void didChangeDependencies () {
178
+ super .didChangeDependencies ();
179
+ if (! _isDataLoaded) {
180
+ _isDataLoaded = true ;
181
+ _loadData ();
182
+ }
183
+ }
184
+
172
185
@override
173
186
Widget build (BuildContext context) {
174
187
final props = widget.node.properties;
@@ -201,8 +214,15 @@ class _PassiveWebViewWidgetState extends State<PassiveWebViewWidget> {
201
214
return buildWebView (properties);
202
215
}
203
216
204
- String buildGoogleMapsURL (GoogleMapsWebViewProperties properties) =>
205
- _buildHtmlContent (properties.src);
217
+ String buildGoogleMapsURL (GoogleMapsWebViewProperties properties) {
218
+ final String ? originalSrc = properties.src;
219
+ final String ? updatedSrc = originalSrc != null
220
+ ? PropertyValueDelegate .getVariableValueFromPath <String >(
221
+ context, originalSrc) ??
222
+ originalSrc
223
+ : null ;
224
+ return _buildHtmlContent (updatedSrc);
225
+ }
206
226
207
227
String _buildHtmlContent (String ? src) {
208
228
final String html = src? .replaceAll ('\n ' , '' ) ?? 'about:blank' ;
@@ -225,8 +245,15 @@ class _PassiveWebViewWidgetState extends State<PassiveWebViewWidget> {
225
245
return buildWebView (properties);
226
246
}
227
247
228
- String buildTwitterURL (TwitterWebViewProperties properties) =>
229
- _buildHtmlContent (properties.src);
248
+ String buildTwitterURL (TwitterWebViewProperties properties) {
249
+ final String ? originalSrc = properties.src;
250
+ final String ? updatedSrc = originalSrc != null
251
+ ? PropertyValueDelegate .getVariableValueFromPath <String >(
252
+ context, originalSrc) ??
253
+ originalSrc
254
+ : null ;
255
+ return _buildHtmlContent (updatedSrc);
256
+ }
230
257
231
258
Widget buildTwitterWebView (
232
259
BuildContext context, TwitterWebViewProperties properties) {
0 commit comments