2

image for the problem

part of code

Future getData() async {
    var url = Uri.parse("https://10.0.2.2:8000/drop/");
    var res = await http.get(url);
    var resb = jsonDecode(res.body);
    return (resb);
nbk
  • 45,398
  • 8
  • 30
  • 47

2 Answers2

0

maybe its a http , https problem did you try it like this without parsing the url ?

Future getData() async {
    var res = await http.get("https://10.0.2.2:8000/drop/");
    var resb = jsonDecode(res.body);
    return (resb); 

or like this :

Future getData() async {
    var url = Uri.tryParse("https://10.0.2.2:8000/drop/");
    var res = await http.get(url);
    var resb = jsonDecode(res.body);
    return (resb);

also this happens when an HTTPS client reaches an HTTP endpoint

Fahmi Sawalha
  • 682
  • 6
  • 19
0

it should be with htos

var url = Uri.https('10.0.2.2:8000', 'drop/')

see manual

nbk
  • 45,398
  • 8
  • 30
  • 47
  • my guess is that your certificate doesn't support tls 1.2, what happens if you open it in a browser? – nbk Apr 23 '21 at 20:17
  • https://stackoverflow.com/questions/46135757/ssl-handshake-error-on-self-signed-cert-in-flutter confirms it, your selfsigned certificate isn't correct – nbk Apr 23 '21 at 20:21
  • its give problem in a browser too .. how i make it support tls 1.2 ?? – Alaaedine Awata Apr 23 '21 at 21:19
  • as i don't know what you did, i can even postulate a solution, maybe you haven't the right key https://stackoverflow.com/questions/16480846/x-509-private-public-key or you didn't bind the key to the port. – nbk Apr 23 '21 at 21:59
  • its work for a link online but doesn't for Localhost – Alaaedine Awata Apr 23 '21 at 23:24
  • online most have a valid ssl certificate, at localhost you need to bind it to work https://learn.microsoft.com/de-de/dotnet/framework/wcf/feature-details/how-to-configure-a-port-with-an-ssl-certificate – nbk Apr 23 '21 at 23:46