postUrl method
- @SupportedPlatforms.new(platforms: [AndroidPlatform(apiName: 'WebView.postUrl', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#postUrl(java.lang.String,%20byte[])'), IOSPlatform(), MacOSPlatform(), WebPlatform(note: 'It will try to create an XMLHttpRequest and load the result inside the iframe.'), WindowsPlatform(), LinuxPlatform(note: 'Uses JavaScript to create an XMLHttpRequest and load the result.')])
Loads the given url with postData (x-www-form-urlencoded) using POST method into this WebView.
Example:
var postData = Uint8List.fromList(utf8.encode("firstname=Foo&surname=Bar"));
controller.postUrl(url: WebUri("https://www.example.com/"), postData: postData);
Officially Supported Platforms/Implementations:
- Android WebView (Official API - WebView.postUrl)
- iOS WKWebView
- macOS WKWebView
- Web <iframe> but requires same origin:
- It will try to create an XMLHttpRequest and load the result inside the iframe.
- Windows WebView2
- Linux WPE WebKit:
- Uses JavaScript to create an XMLHttpRequest and load the result.
Parameters - Officially Supported Platforms/Implementations:
url: all platformspostData: all platforms
Use the PlatformInAppWebViewController.isMethodSupported method to check if this method is supported at runtime.
Implementation
@SupportedPlatforms(
platforms: [
AndroidPlatform(
apiName: 'WebView.postUrl',
apiUrl:
'https://developer.android.com/reference/android/webkit/WebView#postUrl(java.lang.String,%20byte[])',
),
IOSPlatform(),
MacOSPlatform(),
WebPlatform(
note:
'It will try to create an XMLHttpRequest and load the result inside the iframe.',
),
WindowsPlatform(),
LinuxPlatform(
note:
'Uses JavaScript to create an XMLHttpRequest and load the result.',
),
],
)
Future<void> postUrl({required WebUri url, required Uint8List postData}) {
throw UnimplementedError(
'${PlatformInAppWebViewControllerMethod.postUrl.name} is not implemented on the current platform',
);
}