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
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With