Hi how are u? I wanted to know why I wouldn't be able to connect to the Api Rest (made in python Flask Localhost) from my cell phone (I use it as a divice with the cable, I don't use the emulator). I don't know if maybe something needs to be configured in android. I read somewhere that you have to put it in the AndroidManifest.xml
android:usesCleartextTraffic="true"
I put it in but it still doesn't work. I have tried using “localHost” “10.0.0.2” “http://127.0.0.1:8000/” but nothing works. I don't know what I'm doing wrong, I send you my code
class AuthService extends ChangeNotifier{
final String _baseurl= 'http://10.0.2.2:8000';
Future<String> login(String email, String password) async{
final Map<String,dynamic> authData={
'email':email,
'password':password,
// 'returnSecureToken':true
};
final url= Uri.http(_baseurl, 'api/auth'
// {
// 'key':_apiToken
// }
);
final resp= await http.post(url,body:json.encode(authData));
final Map<String,dynamic> decodeResp =json.decode(resp.body);
print(resp);
return decodeResp[0];
}
}
If you can help me I would really appreciate it, I'm really going crazy trying to find the answer.