【发布时间】:2021-12-07 05:02:06
【问题描述】:
我在实现拉动以刷新颤动的 WebView 时遇到问题。我的应用程序由单屏和当前网页组成。当我尝试使用 RefreshIndicator 时,我很困惑如何实现,但它没有用。 这是我的代码
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: PreferredSize(
preferredSize: MediaQuery.of(context).size * 0.05,
child: AppBar(
//leading: Image.asset(gnTabIcon),
elevation: 3.5,
shadowColor: AppColors.navyBlue,
backgroundColor: AppColors.orange,
title: const Text(title),
actions: <Widget>[
NavigationControls(_controller.future), // control navigation
],
),
),
// build scaffold for main app
body: Builder(
builder: (BuildContext context) {
return Stack(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 15.0),
child: WebView(
gestureNavigationEnabled: false,
initialUrl: url,
javascriptMode: JavascriptMode.unrestricted,
zoomEnabled: false, // disable pinch to zoom
onWebViewCreated: (webViewController) {
print('WebView is created');
_controller.complete(webViewController);
},
onProgress: (int progress) {
print("WebView is loading (progress : $progress%)");
splashScreenDelay(progress);
},
javascriptChannels: <JavascriptChannel>{
_toasterJavascriptChannel(context),
},
onPageStarted: (String url) {
print('Page started loading: $url');
_loadingStateTrue();
},
onPageFinished: (String url) {
print('Page finished loading: $url');
_loadingStateFalse();
},
),
),
isLoading
? Center(
child: GnLoader(),
)
: Stack(),
],
);
},
),
);
}
我曾尝试在互联网上进行搜索,但由于方法不同且令人困惑,因此没有任何效果。请帮我。谢谢
【问题讨论】: