首页 > 解决方案 > 如何在 Flutter 的 WebView 中使用 post 方法

问题描述

我想在 Flutter 的 webView 中使用 JSON 格式的数据集进行发布请求。在这里找不到出路。我已经尝试过flutter_inappwebview 4.0.0+4但到目前为止还没有运气。这是我的代码片段:

InAppWebView(
          initialHeaders: header,
          initialOptions: InAppWebViewGroupOptions(
              crossPlatform: InAppWebViewOptions(
            debuggingEnabled: true,
          )),
          onWebViewCreated: (InAppWebViewController controller) {
            webView = controller;
            webView.postUrl(
                url: url,
                postData: utf8.encode(postData.toString()));
          },
          onLoadStart: (InAppWebViewController controller, String url) {
            setState(() {
              this.url = url;
            });
          },
          onLoadStop:
              (InAppWebViewController controller, String url) async {
            setState(() {
              this.url = url;
            });
          },
          onProgressChanged:
              (InAppWebViewController controller, int progress) {
            setState(() {
              this.progress = progress / 100;
            });
          },
        ),

这里headerpostdata两者都是 JSON 格式的数据集。有没有办法解决这个问题?提前致谢。

标签: androidflutterpostwebviewhttp-post

解决方案


推荐阅读