问题描述
我构建了一个WebView应用程序,我想下拉屏幕来刷新网页。我将flutter_inappwebview用于网络视图。我尝试将WebView包装在SingleChildScrollView或ListView中,但是它们都不起作用。在下面的代码中,滑动功能有效时WebView不可滚动。
一段时间以来,我一直在寻找解决方案,但找不到。任何帮助将不胜感激!
@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),],);
}
解决方法
这可能是您的正确答案->
curl "https://{ID}:{password}@{IP}:{port}/api/v1/templates/Applications/Folder{IDFolder}/create" -i -X POST -H "Content-Type:application/json" -H "Accept:application/json" -d @%0\..\ReleaseConfig.json
,
如果使用pull_to_refresh包,它实际上非常简单。您所要做的就是查看其演示代码的底部,并用您的inappwebview支架替换listview构建器。
child: ListView.builder(),-> child: Scaffold(),
也不要忘记添加您的webView.reload();拉。
包裹@ https://pub.dev/packages/pull_to_refresh
#EDIT 抱歉,我不明白问题在于在webview中滚动。我复制了问题,然后,因为我使用了tabview控制器
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
new Factory<OneSequenceGestureRecognizer>(
() => new EagerGestureRecognizer(),),].toSet(),
这解决了问题,如果不是,则归因于使用扩展子级。