Skip to content

a switch turn on off Scaffold. #288

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

Closed
wants to merge 1 commit into from
Closed
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
43 changes: 40 additions & 3 deletions lib/src/webview_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class WebviewScaffold extends StatefulWidget {
this.hidden = false,
this.initialChild,
this.allowFileURLs,
this.withScaffold = true,
}) : super(key: key);

final PreferredSizeWidget appBar;
Expand All @@ -52,7 +53,7 @@ class WebviewScaffold extends StatefulWidget {
final bool hidden;
final Widget initialChild;
final bool allowFileURLs;

final bool withScaffold;
@override
_WebviewScaffoldState createState() => _WebviewScaffoldState();
}
Expand Down Expand Up @@ -90,7 +91,7 @@ class _WebviewScaffoldState extends State<WebviewScaffold> {

@override
Widget build(BuildContext context) {
return Scaffold(
return widget.withScaffold?Scaffold(
appBar: widget.appBar,
persistentFooterButtons: widget.persistentFooterButtons,
bottomNavigationBar: widget.bottomNavigationBar,
Expand Down Expand Up @@ -127,8 +128,44 @@ class _WebviewScaffoldState extends State<WebviewScaffold> {
}
}
},
child: widget.initialChild ?? const Center(child: const CircularProgressIndicator()),
child: widget.initialChild ??
const Center(child: const CircularProgressIndicator()),
),
): _WebviewPlaceholder(
onRectChanged: (Rect value) {
if (_rect == null) {
_rect = value;
webviewReference.launch(
widget.url,
headers: widget.headers,
withJavascript: widget.withJavascript,
clearCache: widget.clearCache,
clearCookies: widget.clearCookies,
hidden: widget.hidden,
enableAppScheme: widget.enableAppScheme,
userAgent: widget.userAgent,
rect: _rect,
withZoom: widget.withZoom,
withLocalStorage: widget.withLocalStorage,
withLocalUrl: widget.withLocalUrl,
scrollBar: widget.scrollBar,
supportMultipleWindows: widget.supportMultipleWindows,
appCacheEnabled: widget.appCacheEnabled,
allowFileURLs: widget.allowFileURLs,
);
} else {
if (_rect != value) {
_rect = value;
_resizeTimer?.cancel();
_resizeTimer = Timer(const Duration(milliseconds: 250), () {
// avoid resizing to fast when build is called multiple time
webviewReference.resize(_rect);
});
}
}
},
child: widget.initialChild ??
const Center(child: const CircularProgressIndicator()),
);
}
}
Expand Down