loadUrl method

  1. @SupportedPlatforms.new(platforms: [AndroidPlatform(apiName: 'WebView.loadUrl', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String)', note: 'If method is "POST", [Official API - WebView.postUrl](https://developer.android.com/reference/android/webkit/WebView#postUrl(java.lang.String,%20byte[])). Also, when loading an URL Request using "POST" method, headers are ignored.'), IOSPlatform(apiName: 'WKWebView.load', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1414954-load', note: 'If [allowingReadAccessTo] is used, [Official API - WKWebView.loadFileURL](https://developer.apple.com/documentation/webkit/wkwebview/1414973-loadfileurl)'), MacOSPlatform(apiName: 'WKWebView.load', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1414954-load', note: 'If [allowingReadAccessTo] is used, [Official API - WKWebView.loadFileURL](https://developer.apple.com/documentation/webkit/wkwebview/1414973-loadfileurl)'), WebPlatform(note: 'If method is "GET" and headers are empty, it will change the `src` of the iframe. For all other cases it will try to create an XMLHttpRequest and load the result inside the iframe.'), WindowsPlatform(apiName: 'ICoreWebView2_2.NavigateWithWebResourceRequest', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_2?view=webview2-1.0.2210.55#navigatewithwebresourcerequest'), LinuxPlatform(apiName: 'webkit_web_view_load_uri', apiUrl: 'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/method.WebView.load_uri.html')])
Future<void> loadUrl({
  1. required URLRequest urlRequest,
  2. @Deprecated('Use allowingReadAccessTo instead') Uri? iosAllowingReadAccessTo,
  3. @SupportedPlatforms.new(platforms: [IOSPlatform(), MacOSPlatform()]) WebUri? allowingReadAccessTo,
})

Loads the given urlRequest.

  • allowingReadAccessTo, used in combination with urlRequest (using the file:// scheme), it represents the URL from which to read the web content. This URL must be a file-based URL (using the file:// scheme). Specify the same value as the URL parameter to prevent WebView from reading any other content. Specify a directory to give WebView permission to read additional files in the specified directory.

Officially Supported Platforms/Implementations:

Parameters - Officially Supported Platforms/Implementations:

  • urlRequest: all platforms
  • allowingReadAccessTo:
    • iOS WKWebView
    • macOS WKWebView

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

Implementation

@SupportedPlatforms(
  platforms: [
    AndroidPlatform(
      apiName: 'WebView.loadUrl',
      apiUrl:
          'https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String)',
      note:
          'If method is "POST", [Official API - WebView.postUrl](https://developer.android.com/reference/android/webkit/WebView#postUrl(java.lang.String,%20byte[])). Also, when loading an URL Request using "POST" method, headers are ignored.',
    ),
    IOSPlatform(
      apiName: 'WKWebView.load',
      apiUrl:
          'https://developer.apple.com/documentation/webkit/wkwebview/1414954-load',
      note:
          'If [allowingReadAccessTo] is used, [Official API - WKWebView.loadFileURL](https://developer.apple.com/documentation/webkit/wkwebview/1414973-loadfileurl)',
    ),
    MacOSPlatform(
      apiName: 'WKWebView.load',
      apiUrl:
          'https://developer.apple.com/documentation/webkit/wkwebview/1414954-load',
      note:
          'If [allowingReadAccessTo] is used, [Official API - WKWebView.loadFileURL](https://developer.apple.com/documentation/webkit/wkwebview/1414973-loadfileurl)',
    ),
    WebPlatform(
      note:
          'If method is "GET" and headers are empty, it will change the `src` of the iframe. For all other cases it will try to create an XMLHttpRequest and load the result inside the iframe.',
    ),
    WindowsPlatform(
      apiName: 'ICoreWebView2_2.NavigateWithWebResourceRequest',
      apiUrl:
          'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_2?view=webview2-1.0.2210.55#navigatewithwebresourcerequest',
    ),
    LinuxPlatform(
      apiName: 'webkit_web_view_load_uri',
      apiUrl:
          'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/method.WebView.load_uri.html',
    ),
  ],
)
Future<void> loadUrl({
  required URLRequest urlRequest,
  @Deprecated('Use allowingReadAccessTo instead')
  Uri? iosAllowingReadAccessTo,
  @SupportedPlatforms(platforms: [IOSPlatform(), MacOSPlatform()])
  WebUri? allowingReadAccessTo,
}) {
  throw UnimplementedError(
    '${PlatformInAppWebViewControllerMethod.loadUrl.name} is not implemented on the current platform',
  );
}