this the code
class WeatherModel {
final String? date;
final double? temp;
final double? maxTemp;
final double? minTemp;
final String? weatherStateName;
WeatherModel(
{required this.date,
required this.temp,
required this.maxTemp,
required this.minTemp,
required this.weatherStateName});
factory WeatherModel.fromJson(dynamic data) {
var jsonData = data['forecast']?['forecastday']?[0]?['day'];
print('$jsonData');
return WeatherModel(
date: data['location']?['localtime'],
temp: jsonData?['avgtemp_c'],
maxTemp: jsonData?['maxtemp_c'],
minTemp: jsonData?['mintemp_c'],
weatherStateName: jsonData?['condition']?['text']);
}
@override
String toString() {
return 'tem = $temp minTemp = $minTemp date = $date';
}
}
this the image [https://i.stack.imgur.com/T6HV9.png]
this the result when I execute the code
I/flutter ( 5213): tem = null minTemp = null date = 2022-08-25 20:26