getJson method
Implementation
Future<dynamic> getJson(String url, {Map<String, String> headers = const {}}) async {
var client = new HttpClient();
var req = await client.getUrl(Uri.parse(url));
headers.forEach((key, value) {
req.headers.add(key, value);
});
var response = await req.close();
client.close();
final contents = StringBuffer();
await for (var data in response.transform(utf8.decoder)) {
contents.write(data);
}
return jsonDecode(contents.toString());
}