loadRequest method

  1. @override
Future<void> loadRequest(
  1. LoadRequestParams params
)

Makes a specific HTTP request ands loads the response in the webview.

WebViewRequest.method must be one of the supported HTTP methods in WebViewRequestMethod.

If WebViewRequest.headers is not empty, its key-value pairs will be added as the headers for the request.

If WebViewRequest.body is not null, it will be added as the body for the request.

Throws an ArgumentError if WebViewRequest.uri has empty scheme.

Implementation

@override
Future<void> loadRequest(LoadRequestParams params) {
  if (!params.uri.hasScheme) {
    throw ArgumentError(
      'LoadRequestParams#uri is required to have a scheme.',
    );
  }

  return _webView.loadRequest(NSUrlRequest(
    url: params.uri.toString(),
    allHttpHeaderFields: params.headers,
    httpMethod: params.method.name,
    httpBody: params.body,
  ));
}