I'm using the webview_fluttter plugin, but I can't find a way to show a CircularProgressIndicator before the webview shows the page...
What's the equivalent of Androids WebViewClient onPageStarted/onPageFinished?
WebView( initialUrl: url, onWebViewCreated: (controller) { }, )
In version 0.3.5 there is 'onPageFinished' callback. You can create WebView container with IndexedStack.
import 'package:flutter/material.dart'; import 'package:webview_flutter/webview_flutter.dart'; class _WebViewContainerState extends State < WebViewContainer > { var _url; final _key = UniqueKey(); _WebViewContainerState(this._url); num _stackToView = 1; void _handleLoad(String value) { setState(() { _stackToView = 0; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(), body: IndexedStack( index: _stackToView, children: [ Column( children: < Widget > [ Expanded( child: WebView( key: _key, javascriptMode: JavascriptMode.unrestricted, initialUrl: _url, onPageFinished: _handleLoad, ) ), ], ), Container( color: Colors.white, child: Center( child: CircularProgressIndicator(), ), ), ], ) ); } } class WebViewContainer extends StatefulWidget { final url; WebViewContainer(this.url); @override createState() => _WebViewContainerState(this.url); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With