I want to connect my localhost and take a token with my parameters.When I was connecting in my device with this code I have an error connection refused!
Here is my code.
class _MyHomePageState extends State<MyHomePage> {
var formContent = {
"grant_type": "1",
"branchcode": "0",
"password": "1",
"username": "1",
"dbname": "1",
"dbuser": "1",
"dbpassword": "1",
"dbtype": "0"
};
Future<String> getData() async {
var postBody= json.encode(formContent);
var response = await http.post(
Uri.encodeFull("http://localhost:7070/api/v2/token"),
body:postBody,
headers: {"Accept": "application/json"});
if(response.statusCode == 200){
return String.fromCharCode(json.decode(response.body));
}else{
throw Exception('Failed');
}
}
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Center(
child: new RaisedButton(
child: new Text("Get The Data"),
onPressed: getData,
),
),
);
}
}
I cannot connect my localhost with my own values. I have an error like connection refused but I don't understand why ?
Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 40109