XMLHttpRequest Cross origin requests In Dart with IntelliJ


I’m loading a json file relatively using dart’s html library’s HttpRequest class. In the Dart editor it’s working fine. Using the dart plugin for intelliJ with JetBrains chrome extension I receive…

XMLHttpRequest cannot load file:///C:/project/web/path/to/my/file.json. Cross origin requests are only supported for HTTP.  :0
Exception: Error: NETWORK_ERR: XMLHttpRequest Exception 101
Stack Trace: #0      HttpRequest.send (file:///E:/b/build/slave/dartium-win-full-trunk/build/src/build/Release/obj/global_intermediate/webkit/bindings/dart/dart/html/HttpRequest.dart:33:3)

I’m passing a relative url, when inspecting the URL I see its:

Here’s the bare bones test.

import 'dart:html';

  Loader loader = new Loader();

class Loader {
  load(String url) {
    var request = new HttpRequest();
    request.open('GET', url, true);


I am not sure why it works in one context and not another, but basically cannot just go GET a file if you are not using http. See these for details on why this is the case. I’ve never used IntelliJ, so I cannot speak to the specifics of that context, unfortunately.


Answered By – Shailen Tuli

Answer Checked By – Cary Denson (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *