Initial Commit
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user