loadUrl method Null safety

Future<void> loadUrl(
  1. {required URLRequest urlRequest,
  2. Uri? iosAllowingReadAccessTo}
)

Loads the given urlRequest.

iosAllowingReadAccessTo, used in combination with urlRequest (using the file:// scheme), is an iOS-specific argument that 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.

NOTE for Android: when loading an URL Request using "POST" method, headers are ignored.

Official Android API: https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String)

Official iOS API:

Implementation

Future<void> loadUrl(
    {required URLRequest urlRequest, Uri? iosAllowingReadAccessTo}) async {
  assert(urlRequest.url != null && urlRequest.url.toString().isNotEmpty);
  assert(iosAllowingReadAccessTo == null ||
      iosAllowingReadAccessTo.isScheme("file"));

  Map<String, dynamic> args = <String, dynamic>{};
  args.putIfAbsent('urlRequest', () => urlRequest.toMap());
  args.putIfAbsent(
      'allowingReadAccessTo', () => iosAllowingReadAccessTo?.toString());
  await _channel.invokeMethod('loadUrl', args);
}