here is package http package.
here is a complete method to get a response.
HttpClient client = new HttpClient()
..badCertificateCallback =
((X509Certificate cert, String host, int port) => true);
return client.getUrl(Uri.parse(url)).then((HttpClientRequest request) {
request.headers.set('content-type', 'application/json-patch+json');
request.headers.set('accept', 'application/json');
var response = request.close().timeout(new Duration(seconds: 5));
return response;
}).then((HttpClientResponse response) {
var result = response.transform(utf8.decoder).join();
return result;
}).catchError((onError) {
var result = onError.transform(utf8.decoder).join();
return result;
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…