我试图在等待网络时添加一个CircularProgressIndicator 页面加载,然后页面显示和圆形指示器 没有显示在屏幕上。在android设备中工作,但在ios设备中 不起作用,为什么?
我的代码:
dynamic progress = 0 ;
return SafeArea(
child: Scaffold(
appBar: AppBar(
actions: <Widget>[
IconButton(
icon: Icon(Icons.arrow_forward_ios),
onPressed: _onBack,
),
],
//actions: <Widget>[NavigationControlls(_controller.future)],
),
body: new Builder(builder: (BuildContext contixt) {
return Container(
child: Stack(
children: <Widget>[
WillPopScope(
onWillPop: _onBack,
child: SafeArea(
child: InAppWebView(
initialUrl: url,
onWebViewCreated:
(InAppWebViewController webViewController) {
controller = webViewController;
},
onLoadStart: (InAppWebViewController controller,
String url) {},
onProgressChanged:
(InAppWebViewController controller,
int progress) {
setState(() {
this.progress = progress / 100;
});
},
),
),
),
Align(
alignment: Alignment.center,
child: _buildProgressBarIOS()),
],
),
);
})),
);
_buildProgressBarIOS()方法:
Widget _buildProgressBarIOS() {
if (progress != 1.0) {
return Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
CupertinoActivityIndicator(
animating: false,
radius: 50,
),
],
),
);
}
return Container();
}
答案 0 :(得分:1)
创建一个返回Web视图的函数,然后执行以下操作:-
body: new Builder(builder: (BuildContext context) {
return progress == 100.0 ? yourInAppWebView() : circularIndicator();
}