'Why flutter http response in web missing headers?

I am making a simple flutter app using http package. I am trying to send a (post) login request, and the httpresponse is missing all the headers! this works fine in ios simulator but in chrome as you can see there are only 2 headers available; enter image description here

enter image description here

What is wrong? Thanks



Solution 1:[1]

I have the following:

Response headers web:

"Origin":"http://localhost:57986"

Example code:

Future<File> downloadFile(String url, String pathFile) async {
     File file = new File(pathFile);
     var request = await http.post(Uri.parse(url), encoding: Encoding.getByName('utf8'), headers: {
       "Access-Control-Allow-Origin": "*",
       "Access-Control-Allow-Methods": "POST, GET, OPTIONS, PUT, DELETE, HEAD",
     });
     if (request.statusCode == 200) {
       Map<String, String> headers = request.headers;
       if (headers.containsKey("Origin")) {
         var origin = headers['Origin'];
         print("your result: " + origin.toString());
       }
       file.writeAsBytes(request.bodyBytes);
     }
     return file;
   }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JJGV