query static method
Sends a GET request to url
with optional client
and returns the
response body or null
if any exception happens.
Implementation
static Future<String?> query(Uri url, {http.Client? client}) async {
client = client ?? http.Client();
try {
final response = await client.get(url);
if (response.statusCode != 200) {
throw Exception(
'Expected status code 200 but got ${response.statusCode} - ${response.body}',
);
}
return response.body;
} catch (exception) {
return null;
}
}