错误:未为类“_PaymentScreenState”定义方法“WebView”

问题描述 投票:0回答:1

我需要帮助来实现 Webview 的更新版本,该版本分为两部分。该错误将 webview 突出显示为未定义。当我尝试实现新版本时,我不断收到错误,因此我决定向社区寻求帮助来与我一起解决这个问题,以便我充分了解它是如何完成的。

 @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () => _exitApp(context),
      child: Scaffold(
        backgroundColor: Colors.white,
        appBar: AppBar(
          title: Text("payment".tr),
          leading: IconButton(
            icon: Icon(Icons.arrow_back_ios),
            onPressed:()=> _exitApp(context),
          ),
          backgroundColor: AppColors.mainColor,
        ),
        body: Center(
          child: Container(
            width: Dimensions.WEB_MAX_WIDTH,
            child: Stack(
              children: [
                **WebView**(
                  initialUrl: selectedUrl,
                  javaScriptMode: JavaScriptMode.unrestricted,
                  gestureNavigationEnabled: true,
                  userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_3 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13E233 Safari/601.1',
                  onWebViewCreated: (WebViewController webViewController) {
                    _controller.future.then((value) => controllerGlobal = value);
                    _controller.complete(webViewController);
                   // _controller.future.catchError(webViewController);
                  },
                  onProgress: (int progress) {
                    print("WebView is loading (progress : $progress%)");
                    print("url is "+ selectedUrl.toString());
                  },
                  onPageStarted: (String url) {
                    setState(() {
                      _isLoading = true;
                    });
                    _redirect(url);
                    print("finishing...0");
                  },
                  onPageFinished: (String url) {
                    setState(() {
                      _isLoading = false;
                    });
                    print("finishing...");
                    _redirect(url);
                  },
                ),
                _isLoading ? Center(
                  child: CircularProgressIndicator(valueColor: AlwaysStoppedAnimation<Color>(Theme.of(context).primaryColor)),
                ) : SizedBox.shrink(),
              ],
            ),
          ),
        ),
      ),
    );
  }
android ios flutter dart webview
1个回答
0
投票

确保您指定了软件包版本。而不是使用 null 作为版本

© www.soinside.com 2019 - 2024. All rights reserved.