22 lines
592 B
Dart
22 lines
592 B
Dart
import 'package:wetter/models/hourly_weather_model.dart';
|
|
|
|
class DailyWeatherModel {
|
|
late List<HourlyWeatherModel> hourlyForecasts;
|
|
|
|
DailyWeatherModel.fromJson(Map<String, dynamic> json) {
|
|
List dataPoints = json['weather'];
|
|
hourlyForecasts = [];
|
|
for (var dataPoint in dataPoints) {
|
|
hourlyForecasts.add(HourlyWeatherModel.fromJson(dataPoint));
|
|
}
|
|
}
|
|
|
|
String dailyAverageTemp() {
|
|
double tempSum = 0;
|
|
for (var forecast in hourlyForecasts) {
|
|
tempSum = tempSum + forecast.temperature;
|
|
}
|
|
return (tempSum / hourlyForecasts.length).toString();
|
|
}
|
|
}
|