Future<void> _loginRequest() async {
if(_formKey.currentState.validate()) {
try {
final String CRLF = '\n';
final String point = _login;
final String password = _password;
final String md5FromServerText = "test" + point + password;
final String md5FromServer = (md5.convert(utf8.encode(md5FromServerText)).toString()).toUpperCase();
final String body = "test" + CRLF + "point_id=" + point + CRLF + "md5=" + md5FromServer + CRLF;
final String uri = 'http://site.ru:8080/company/Controller';
final response = await http.post(
uri,
body: body,
headers: {
'Content-Type': 'text/plain',
'charset': 'windows-1251',
'Content-Length': (body.length).toString(),
'Point': point,
'Point_type': 'terminal'
}
);
_status = response.statusCode;
_body = response.body;
if(_status == 200) {
print(_body);
Scaffold
.of(context)
.showSnackBar(
SnackBar(
content: Text(_body),
backgroundColor: Colors.green,
)
);
}
} catch (error) {
_status = 0;
_body = error.toString();
Scaffold
.of(context)
.showSnackBar(
SnackBar(
content: Text(_body),
backgroundColor: Colors.red,
)
);
}
setState(() {});
}
}
Статус выдает 200, а тело выдает "-1java.lang.NullPointerException"