Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds 'hiddenUntilFinishLoad' param #732

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/src/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class FlutterWebviewPlugin {
/// - [clearCache] clear the cache of the Webview
/// - [clearCookies] clear all cookies of the Webview
/// - [hidden] not show
/// - [hiddenUntilFinishLoad] stay hidden until finishLoad event
/// - [rect]: show in rect, fullscreen if null
/// - [enableAppScheme]: false will enable all schemes, true only for httt/https/about
/// android: Not implemented yet
Expand Down Expand Up @@ -150,6 +151,7 @@ class FlutterWebviewPlugin {
bool clearCookies,
bool mediaPlaybackRequiresUserGesture,
bool hidden,
bool hiddenUntilFinishLoad,
bool enableAppScheme,
Rect rect,
String userAgent,
Expand All @@ -174,6 +176,7 @@ class FlutterWebviewPlugin {
'withJavascript': withJavascript ?? true,
'clearCache': clearCache ?? false,
'hidden': hidden ?? false,
'hiddenUntilFinishLoad': hiddenUntilFinishLoad ?? true,
'clearCookies': clearCookies ?? false,
'mediaPlaybackRequiresUserGesture': mediaPlaybackRequiresUserGesture ?? true,
'enableAppScheme': enableAppScheme ?? true,
Expand Down
8 changes: 4 additions & 4 deletions lib/src/webview_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class WebviewScaffold extends StatefulWidget {
this.supportMultipleWindows,
this.appCacheEnabled,
this.hidden = false,
this.hiddenUntilFinishLoad = true,
this.initialChild,
this.allowFileURLs,
this.resizeToAvoidBottomInset = false,
Expand Down Expand Up @@ -65,6 +66,7 @@ class WebviewScaffold extends StatefulWidget {
final bool supportMultipleWindows;
final bool appCacheEnabled;
final bool hidden;
final bool hiddenUntilFinishLoad;
final Widget initialChild;
final bool allowFileURLs;
final bool resizeToAvoidBottomInset;
Expand Down Expand Up @@ -110,7 +112,7 @@ class _WebviewScaffoldState extends State<WebviewScaffold> {
}
});

if (widget.hidden) {
if (widget.hidden && widget.hiddenUntilFinishLoad) {
_onStateChanged =
webviewReference.onStateChanged.listen((WebViewStateChanged state) {
if (state.type == WebViewState.finishLoad) {
Expand All @@ -136,9 +138,7 @@ class _WebviewScaffoldState extends State<WebviewScaffold> {
_onBack?.cancel();
_resizeTimer?.cancel();
webviewReference.close();
if (widget.hidden) {
_onStateChanged.cancel();
}
_onStateChanged?.cancel();
webviewReference.dispose();
}

Expand Down