getUrl method

  1. @SupportedPlatforms.new(platforms: [AndroidPlatform(apiName: 'WebView.getUrl', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#getUrl()'), IOSPlatform(apiName: 'WKWebView.url', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1415005-url'), MacOSPlatform(apiName: 'WKWebView.url', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1415005-url'), WebPlatform(note: "For a same-origin iframe it returns the current location. After the first document loads, it returns null when the browser's same-origin policy prevents reading a cross-origin location."), WindowsPlatform(apiName: 'ICoreWebView2.get_Source', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#get_source'), LinuxPlatform(apiName: 'webkit_web_view_get_uri', apiUrl: 'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/method.WebView.get_uri.html')])
Future<WebUri?> getUrl()

Gets the URL for the current page. This is not always the same as the URL passed to PlatformWebViewCreationParams.onLoadStart because although the load for that URL has begun, the current page may not have changed.

Officially Supported Platforms/Implementations:

Use the PlatformInAppWebViewController.isMethodSupported method to check if this method is supported at runtime.

Implementation

@SupportedPlatforms(
  platforms: [
    AndroidPlatform(
      apiName: 'WebView.getUrl',
      apiUrl:
          'https://developer.android.com/reference/android/webkit/WebView#getUrl()',
    ),
    IOSPlatform(
      apiName: 'WKWebView.url',
      apiUrl:
          'https://developer.apple.com/documentation/webkit/wkwebview/1415005-url',
    ),
    MacOSPlatform(
      apiName: 'WKWebView.url',
      apiUrl:
          'https://developer.apple.com/documentation/webkit/wkwebview/1415005-url',
    ),
    WebPlatform(
      note:
          "For a same-origin iframe it returns the current location. After the first document loads, it returns null when the browser's same-origin policy prevents reading a cross-origin location.",
    ),
    WindowsPlatform(
      apiName: 'ICoreWebView2.get_Source',
      apiUrl:
          'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#get_source',
    ),
    LinuxPlatform(
      apiName: 'webkit_web_view_get_uri',
      apiUrl:
          'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/method.WebView.get_uri.html',
    ),
  ],
)
Future<WebUri?> getUrl() {
  throw UnimplementedError(
    '${PlatformInAppWebViewControllerMethod.getUrl.name} is not implemented on the current platform',
  );
}