I am trying to fetch weather data from
What is wrong in my code, and how to solve the issue?
CodePudding user response:
try this:
String authority = "api.weatherapi.com";
String apiKey = "bc4512ff6799474cbcc114118222908";
String query = "london";
String unencodedPath = "v1/forecast.json";
final queryParameters = {
'key': apiKey,
'q': query,
'days': 10,
'aqi': 'yes',
'alerts': 'yes',
};
Future getWeatherData() async {
final uri = Uri.https(authority, unencodedPath, queryParameters);
var response = await http.get(uri);;
var jsonData = jsonDecode(response.body);
print(jsonData);
}