I build a WebView app, and I want to pull down the screen to refresh the webpage. I use flutter_inappwebview for the webview. I try to wrap WebView inside SingleChildScrollView or ListView, but none of them work. In below code, WebView is not scrollable while swipe function works.
I have been looking for the solution for sometime, yet I couldn't find it. Any helps would be appreciate!
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () => _onBackPressed(),
child: Scaffold(
body: SafeArea(
child: RefreshIndicator(
onRefresh: () async {
print("##Refresh");
webview.reload();
},
child: SingleChildScrollView(
physics: AlwaysScrollableScrollPhysics(),
child: Container(
height: MediaQuery.of(context).size.height,
child: Center(
child: Stack(
children: <Widget>[
InAppWebView(
gestureRecognizers: Set()
..add(
Factory<VerticalDragGestureRecognizer>(
() => VerticalDragGestureRecognizer(),
),
),
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
debuggingEnabled: true,
userAgent: 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Mobile Safari/537.36',
),
),
onWebViewCreated: (InAppWebViewController controller) {
webview = controller;
controller.loadUrl(url: startURL);
},
onLoadStart: (InAppWebViewController controller, String url) async {
print("##onloadstart: " + url);
},
onLoadStop: (InAppWebViewController controller, String url) async {
print("##onloadstop: $url");
},
onProgressChanged: (InAppWebViewController controller, int progress) {
setState(() {
this.progress = progress / 100;
});
}
),
Align(
alignment: Alignment.center,
child: buildProgressBar(progress),
),
],
),
),
),
),
),
),
),
);
}