fetchGeoInfo method
Fetches geo info JSON from the provided url
and returns
a filtered Map of (String, dynamic) excluding keys in ignoredKeys.
Implementation
@override
Future<Map<String, dynamic>> fetchGeoInfo(Uri url) async {
try {
final response = await http.get(url);
if (response.statusCode == 200) {
final Map<String, dynamic> data = json.decode(response.body);
// Filter out ignored keys
final filteredMap = Map<String, dynamic>.fromEntries(
data.entries.where((entry) => !ignoredKeys.contains(entry.key)),
);
return filteredMap;
} else {
// You can handle non-200 responses here if needed
print('Failed to fetch geo info: ${response.statusCode}');
}
} catch (e, stacktrace) {
print('Error fetching geo info: $e\n$stacktrace');
}
return {};
}