Flutter 颤振-下拉刷新不在Webview内工作

Flutter 颤振-下拉刷新不在Webview内工作,flutter,listview,dart,webview,Flutter,Listview,Dart,Webview,我只是想在webview上添加“下拉刷新”功能。我已添加SmartRefresh,但它不起作用。该软件包严格要求SmartRefresh的子级为ListView,因此在这种情况下,我必须使用ListView。我正在尝试刷新下拉刷新小部件的页面。下面我附上了我试图构建的小部件代码 class CustomWebView extends StatefulWidget { @override _CustomWebViewState createState() => _CustomWebV

我只是想在webview上添加“下拉刷新”功能。我已添加SmartRefresh,但它不起作用。该软件包严格要求SmartRefresh的子级为ListView,因此在这种情况下,我必须使用ListView。我正在尝试刷新下拉刷新小部件的页面。下面我附上了我试图构建的小部件代码

class CustomWebView extends StatefulWidget {
  @override
  _CustomWebViewState createState() => _CustomWebViewState();
}

WebViewController controllerGlobal;
bool connected = false;
Future<bool> _exitApp(BuildContext context) async {
  if (await controllerGlobal.canGoBack()) {
    print("onwill goback");
    controllerGlobal.goBack();
  } else {
    return Future.value(true);
  }
}

class _CustomWebViewState extends State<CustomWebView> {
  final Completer<WebViewController> _controller =
      Completer<WebViewController>();
  bool done = false;
  RefreshController _refreshController =
      RefreshController(initialRefresh: false);
  @override
  Widget build(BuildContext context) {
    double _width = MediaQuery.of(context).size.width;
    double _height = MediaQuery.of(context).size.height;

    FlutterStatusbarcolor.setStatusBarColor(Color(0xff3700b3));
    return WillPopScope(
      onWillPop: () => _exitApp(context),
      child: SafeArea(
        child: Scaffold(
          body: SmartRefresher(
            controller: _refreshController,
            scrollDirection: Axis.vertical,
            footer: SizedBox(),
            header: MaterialClassicHeader(
              color: Color(0xffec0928),
            ),
            onRefresh: () {
              controllerGlobal.reload();
              _refreshController.refreshCompleted();
            },
            child: ListView(
                shrinkWrap: true,
                physics: const NeverScrollableScrollPhysics(),
                children: <Widget>[
                  Container(
                    height: _height,
                    width: _width,
                    child: Stack(
                      children: [
                        FutureBuilder<WebViewController>(
                          future: _controller.future,
                          builder: (BuildContext context,
                              AsyncSnapshot<WebViewController> snapshot) {
                            final WebViewController controller = snapshot.data;
                            controllerGlobal = controller;
                            return Stack(
                              children: [
                                WebView(
                                  initialUrl: 'https://uzamart.com/',
                                  javascriptMode: JavascriptMode.unrestricted,
                                  onWebViewCreated:
                                      (WebViewController webviewController) {
                                    _controller.complete(webviewController);
                                  },
                                  onPageFinished: (String url) {
                                    if (url == 'https://uzamart.com/') {
                                      setState(() {
                                        done = true;
                                      });
                                    }
                                    print('Page finished loading: $url');
                                  },
                                  gestureNavigationEnabled: true,
                                ),
                                !done
                                    ? AlertDialog(
                                        shape: RoundedRectangleBorder(
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(10.0),
                                          ),
                                        ),
                                        title: Row(
                                          children: <Widget>[
                                            CircularProgressIndicator(
                                              valueColor:
                                                  AlwaysStoppedAnimation<Color>(
                                                Color(0xffec0928),
                                              ),
                                            ),
                                            Padding(
                                              padding:
                                                  const EdgeInsets.fromLTRB(
                                                      18.0, 0, 0, 0),
                                              child: Text('Loading...'),
                                            )
                                          ],
                                        ),
                                      )
                                    : SizedBox()
                              ],
                            );
                          },
                        )
                     ]
                   )
                )
              ]
            )
          )
        )
      )
    );
  }
} 
类CustomWebView扩展StatefulWidget{
@凌驾
_CustomWebViewState createState()=>\u CustomWebViewState();
}
WebViewController控制器全局;
布尔连接=假;
Future\u exitap(BuildContext上下文)异步{
if(等待controllerGlobal.canGoBack()){
打印(“onwill goback”);
controllerGlobal.goBack();
}否则{
返回未来值(true);
}
}
类_CustomWebViewState扩展状态{
最终完成器控制器=
完成符();
bool done=false;
刷新控制器\u刷新控制器=
RefreshController(initialRefresh:false);
@凌驾
小部件构建(构建上下文){
double _width=MediaQuery.of(context).size.width;
double _height=MediaQuery.of(context).size.height;
setStatusBarColor(颜色(0xff3700b3));
返回式示波器(
onWillPop:()=>\u exitApp(上下文),
儿童:安全区(
孩子:脚手架(
正文:SmartRefresh(
控制器:\u刷新控制器,
滚动方向:轴垂直,
页脚:SizedBox(),
标题:物料分类标题(
颜色:颜色(0xffec0928),
),
onRefresh:(){
controllerGlobal.reload();
_refreshController.refreshCompleted();
},
子:ListView(
收缩膜:对,
物理学:const NeverScrollableScrollPhysics(),
儿童:[
容器(
高度:_高度,
宽度:_宽度,
子:堆栈(
儿童:[
未来建设者(
未来:_controller.future,
生成器:(BuildContext上下文,
异步快照(快照){
最终WebViewController=snapshot.data;
控制器全局=控制器;
返回堆栈(
儿童:[
网络视图(
初始URL:'https://uzamart.com/',
javascriptMode:javascriptMode.unrestricted,
onWebViewCreated:
(WebViewController WebViewController){
_控制器。完成(webviewController);
},
onPageFinished:(字符串url){
如果(url=='https://uzamart.com/') {
设置状态(){
完成=正确;
});
}
打印('Page finished loading:$url');
},
gestureNavigationEnabled:正确,
),
!完成
?警报对话框(
形状:圆形矩形边框(
borderRadius:borderRadius.all(
圆形半径(10.0),
),
),
标题:世界其他地区(
儿童:[
循环压缩机指示器(
valueColor:
总是被打倒(
颜色(0xffec0928),
),
),
填充物(
衬垫:
const EdgeInsets.fromLTRB(
18.0, 0, 0, 0),
子项:文本('Loading…'),
)
],
),
)
:SizedBox()
],
);
},
)
]
)
)
]
)
)
)
)
);
}
}