i tried to use an api on my localhost but when i run my app i got an error
*Unhandled Exception: HandshakeException: Connection terminated during handshake
here is my function where i got this error
Future
print(json.decode(response.body));
_isLoading = false;
notifyListeners();
return userData;
}
}
With code fencing.
Future<Map<String, dynamic>> login(String email, String password) async {
Map<String, dynamic> userData = {'email': email, 'password': password};
_isLoading = true;
notifyListeners();
http.Response response = await http.post(Uri.encodeFull('https://10.0.2.2:8000/api/login'),
body: json.encode(userData),
headers: {'Content-Type': 'application/json'});
print(json.decode(response.body));
_isLoading = false;
notifyListeners();
return userData;
}
}
I'm not sure what you're trying to do?
What does this have to do with pub?
@jonasfj
i was trying to use api on my localhost but i got Connection terminated during handshake
and i don't know why this error
Use what API? Not sure what you're trying to achieve..
The error is probably a server accepting the TCP connections and then dropping it.. or something like that... Seems like a TCP thing.
Check your URL https://10.0.2.2:8000/api/login
https with port 8000 is most probably wrong ;)
Id try http://10.0.2.2:8000/api/login
call http://10.0.2.2:8000/api/login without s (secure) instead of https://10.0.2.2:8000/api/login
the HTTP is what what's making the handshake exception
This looks unrelated to pub and it looks like there is a suggested solution. I'll close this.
For future questions of this type stack overflow may be a better place to get help.
Most helpful comment
call http://10.0.2.2:8000/api/login without s (secure) instead of https://10.0.2.2:8000/api/login
the HTTP is what what's making the handshake exception