@@ -137,16 +137,13 @@ class WebViewPreviewWidget extends StatelessWidget {
137137class RawWebViewWidget extends StatefulWidget {
138138 final WebViewProperties properties;
139139 final WidgetBuildSettings settings;
140-
141- static const Set <TargetPlatform > supportedPlatforms = {
142- TargetPlatform .android,
143- TargetPlatform .iOS,
144- };
140+ final ValueChanged <WebViewController >? onPageLoaded;
145141
146142 const RawWebViewWidget ({
147143 super .key,
148144 required this .properties,
149145 required this .settings,
146+ this .onPageLoaded,
150147 });
151148
152149 @override
@@ -211,7 +208,7 @@ class _RawWebViewWidgetState extends State<RawWebViewWidget> {
211208 }
212209 }
213210
214- void _loadData () {
211+ Future < void > _loadData () {
215212 final ScopedValues scopedValues = ScopedValues .of (context);
216213 final props = widget.properties;
217214 switch (props.webviewType) {
@@ -225,22 +222,22 @@ class _RawWebViewWidgetState extends State<RawWebViewWidget> {
225222 switch (properties.pageSourceType) {
226223 case WebViewWebpageSourceType .url:
227224 print ('Loading URL: $input ' );
228- _controller.loadRequest (Uri .parse (input));
225+ return _controller.loadRequest (Uri .parse (input));
229226 case WebViewWebpageSourceType .html:
230227 final content = _buildHtmlContent (input);
231- _controller.loadRequest (Uri .parse (content));
228+ return _controller.loadRequest (Uri .parse (content));
232229 case WebViewWebpageSourceType .asset:
233230 // provided from onWebViewCreated callback.
234- _controller.loadFlutterAsset (input);
231+ return _controller.loadFlutterAsset (input);
235232 }
236233 case WebViewType .googleMaps:
237234 final content = buildGoogleMapsURL (
238235 props as GoogleMapsWebViewProperties , scopedValues);
239- _controller.loadRequest (Uri .parse (content));
236+ return _controller.loadRequest (Uri .parse (content));
240237 case WebViewType .twitter:
241238 final content =
242239 buildTwitterURL (props as TwitterWebViewProperties , scopedValues);
243- _controller.loadRequest (Uri .parse (content));
240+ return _controller.loadRequest (Uri .parse (content));
244241 }
245242 }
246243
@@ -253,7 +250,9 @@ class _RawWebViewWidgetState extends State<RawWebViewWidget> {
253250 }
254251 if (! _isDataLoaded) {
255252 _isDataLoaded = true ;
256- _loadData ();
253+ _loadData ().then ((value) {
254+ widget.onPageLoaded? .call (_controller);
255+ });
257256 }
258257 }
259258
0 commit comments