loadUrl method

Future<void> loadUrl({
  1. required URLRequest urlRequest,
})

Implementation

Future<void> loadUrl({required URLRequest urlRequest}) async {
  if ((urlRequest.method == null || urlRequest.method == "GET") &&
      (urlRequest.headers == null || urlRequest.headers!.isEmpty)) {
    iframe.src = urlRequest.url.toString();
  } else {
    try {
      iframe.src = _convertHttpResponseToData(await _makeRequest(urlRequest));
    } catch (e) {
      log(
        'Can\'t load the URLRequest for "${urlRequest.url}". Probably caused by a CORS policy error.',
        name: runtimeType.toString(),
        error: e,
      );
      if (urlRequest.method == null || urlRequest.method == "GET") {
        log(
          'Load the request using just the URL.',
          name: runtimeType.toString(),
          error: e,
        );
        iframe.src = urlRequest.url.toString();
      }
    }
  }
}