For some unknown reason I can't connect to local endpoint on physical device.
Code:
String url = 'http://localhost/eltriodigital/public/api/prueba';
String url2 = 'http://192.168.56.1/eltriodigital/public/api/prueba';
String url3 = 'https://ecleectic.com/api/prueba';
Future<Response> prueba() async {
Response response =
await get(url, headers: {'Content-type': 'application/json'});
return response;
}
Tests I have performed:
If I try to connect to a production endpoint(url3) it works.
If I try to connect to local endpoint(url,url2) but from emulator it works.
If I try to connect to local endpoint(url,url2) from flutter web if it works.
Can someone tell me why I can not connect from physical device in local endpoint(url,url2)? Thanks
CodePudding user response:
Can you check this question How can I access my localhost from my Android device? It may has the solution for your problem