@@ -20,6 +20,8 @@ class WebviewScaffold extends StatefulWidget {
2020 final bool withLocalStorage;
2121 final bool withLocalUrl;
2222 final bool scrollBar;
23+ final bool hidden;
24+ final Widget initialChild;
2325
2426 final Map <String , String > headers;
2527
@@ -39,7 +41,9 @@ class WebviewScaffold extends StatefulWidget {
3941 this .withZoom,
4042 this .withLocalStorage,
4143 this .withLocalUrl,
42- this .scrollBar})
44+ this .scrollBar,
45+ this .hidden : false ,
46+ this .initialChild})
4347 : super (key: key);
4448
4549 @override
@@ -50,17 +54,25 @@ class _WebviewScaffoldState extends State<WebviewScaffold> {
5054 final webviewReference = new FlutterWebviewPlugin ();
5155 Rect _rect;
5256 Timer _resizeTimer;
57+ StreamSubscription <WebViewStateChanged > _onStateChanged;
5358
5459 @override
5560 void initState () {
5661 super .initState ();
5762 webviewReference.close ();
63+
64+ _onStateChanged = webviewReference.onStateChanged.listen ((WebViewStateChanged state) {
65+ if (state.type == WebViewState .finishLoad) {
66+ webviewReference.show ();
67+ }
68+ });
5869 }
5970
6071 @override
6172 void dispose () {
6273 super .dispose ();
6374 webviewReference.close ();
75+ _onStateChanged.cancel ();
6476 webviewReference.dispose ();
6577 }
6678
@@ -79,7 +91,8 @@ class _WebviewScaffoldState extends State<WebviewScaffold> {
7991 withZoom: widget.withZoom,
8092 withLocalStorage: widget.withLocalStorage,
8193 withLocalUrl: widget.withLocalUrl,
82- scrollBar: widget.scrollBar);
94+ scrollBar: widget.scrollBar,
95+ hidden: widget.hidden);
8396 } else {
8497 final rect = _buildRect (context);
8598 if (_rect != rect) {
@@ -95,7 +108,7 @@ class _WebviewScaffoldState extends State<WebviewScaffold> {
95108 appBar: widget.appBar,
96109 persistentFooterButtons: widget.persistentFooterButtons,
97110 bottomNavigationBar: widget.bottomNavigationBar,
98- body: const Center (child: const CircularProgressIndicator ()));
111+ body: widget.initialChild ?? const Center (child: const CircularProgressIndicator ()));
99112 }
100113
101114 Rect _buildRect (BuildContext context) {
0 commit comments