Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Http request are very slow with flutter

Tags:

flutter

dart

When I make an http from flutter to my REST API it takes around 13s to get the result while when I make an http request from my browser it takes around 0.05s. I don't understand why the difference is so big.

Here is my code for the http request :

import 'package:http/http.dart' show Client;

var time1 = DateTime.now().millisecondsSinceEpoch;
final response = await client.get(url, headers: {"Accept": "application/json"});
print(DateTime.now().millisecondsSinceEpoch - time1); // Print about 13s
like image 799
louisld Avatar asked Jul 12 '19 08:07

louisld


People also ask

How do I make HTTP requests work in Flutter Web?

Especially if your flutter web application is not running in the same domain as the server where you api is running. Even if its on the same machine, you will have to allow the request from certain domain and ports. If you are not aware of CORS you can read here.


1 Answers

The problem is about flutter itself and iOS. At the moment it's not fixed. You can follow the ticket already posted on their repo here

like image 142
stefanodecillis Avatar answered Oct 11 '22 00:10

stefanodecillis