webview_flutter
目前没有发送帖子请求的方法。
不过,你可以试试我的flutter_inappwebview插入。它支持POST请求!
使用当前最新版本的简单示例5.0.5+3
of the flutter_inappwebview插件是:
var postData = Uint8List.fromList(utf8.encode("firstname=Foo&lastname=Bar"));
controller.postUrl(url: Uri.parse("https://example.com/my-post-endpoint"), postData: postData);
哪里的postData
是请求的正文x-www-form-urlencoded
format.
例如,如果您有 PHP 服务器,则可以访问firstname
and lastname
像平常一样的值,即$_POST['firstname']
and $_POST['lastname']
.
您还可以初始化InAppWebView
具有如下初始 POST 请求的小部件:
child: InAppWebView(
initialUrlRequest: URLRequest(
url: Uri.parse("https://example.com/my-post-endpoint"),
method: 'POST',
body: Uint8List.fromList(utf8.encode("firstname=Foo&lastname=Bar")),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
),
onWebViewCreated: (controller) {
},
),