Successfully pulling a good weather report. Now to add the heat index and wind chill calculations.

This commit is contained in:
2025-04-25 17:10:22 -07:00
parent b1d01c6915
commit 7e53a2b4e2
3 changed files with 135 additions and 12 deletions

View File

@ -8,7 +8,7 @@ import 'dart:convert';
// Generic method to hit a GET request and return the response.
Future<String> hitAPI(String url) async {
if (debug) debugPrint(url);
if (debug) debugPrint("DEBUG: URL is '$url'.");
http.Response response = await http.get(Uri.parse(url));
@ -16,10 +16,17 @@ Future<String> hitAPI(String url) async {
if (response.statusCode == 200) {
data = response.body;
var decodedData = jsonDecode(data);
if (debugVerbose) debugPrint(decodedData.toString());
data = decodedData.toString();
//data = decodedData.toString();
//data = jsonEncode(decodedData);
if (debugVerbose) {
debugPrint("DEBUG-VERBOSE: Response data: \n\n$data\n");
}
} else {
if (debug) debugPrint(response.statusCode.toString());
if (debug) {
debugPrint(
"DEBUG: Response failed with code '${response.statusCode.toString()}'",
);
}
}
return data;
@ -38,8 +45,3 @@ Future<String> hitOpenWeatherZip(String zipCode, String? countryCode) async {
String data = await hitAPI(url);
return data;
}
// Convert the Future value into a usable value.
loadWeather() async {
return await hitOpenWeatherZip("47630", "US");
}