getOriginalUrl method
- @SupportedPlatforms.new(platforms: [AndroidPlatform(apiName: 'WebView.getOriginalUrl', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#getOriginalUrl()'), IOSPlatform(), LinuxPlatform(apiName: 'webkit_web_view_get_uri', apiUrl: 'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/method.WebView.get_uri.html', note: 'Returns the current URL. WPE WebKit does not distinguish between original and current URL.'), MacOSPlatform(), WebPlatform(note: 'It will return the current value of the `iframe.src` attribute.'), WindowsPlatform(note: 'Returns the current URL. WebView2 does not distinguish between original and current URL.')])
Gets the URL that was originally requested for the current page.
This is not always the same as the URL passed to InAppWebView.onLoadStart because although the load for that URL has begun,
the current page may not have changed. Also, there may have been redirects resulting in a different URL to that originally requested.
Officially Supported Platforms/Implementations:
- Android WebView (Official API - WebView.getOriginalUrl)
- iOS WKWebView
- Linux WPE WebKit (Official API - webkit_web_view_get_uri):
- Returns the current URL. WPE WebKit does not distinguish between original and current URL.
- macOS WKWebView
- Web <iframe> but requires same origin:
- It will return the current value of the
iframe.srcattribute.
- It will return the current value of the
- Windows WebView2:
- Returns the current URL. WebView2 does not distinguish between original and current URL.
Use the PlatformInAppWebViewController.isMethodSupported method to check if this method is supported at runtime.
Implementation
@SupportedPlatforms(
platforms: [
AndroidPlatform(
apiName: 'WebView.getOriginalUrl',
apiUrl:
'https://developer.android.com/reference/android/webkit/WebView#getOriginalUrl()',
),
IOSPlatform(),
LinuxPlatform(
apiName: 'webkit_web_view_get_uri',
apiUrl:
'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/method.WebView.get_uri.html',
note:
'Returns the current URL. WPE WebKit does not distinguish between original and current URL.',
),
MacOSPlatform(),
WebPlatform(
note: 'It will return the current value of the `iframe.src` attribute.',
),
WindowsPlatform(
note:
'Returns the current URL. WebView2 does not distinguish between original and current URL.',
),
],
)
Future<WebUri?> getOriginalUrl() {
throw UnimplementedError(
'${PlatformInAppWebViewControllerMethod.getOriginalUrl.name} is not implemented on the current platform',
);
}