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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
class HourlyWeatherModel {
|
||||
late DateTime timestamp;
|
||||
String? sourceId;
|
||||
double? precipitation;
|
||||
int? pressure;
|
||||
int? sunshine;
|
||||
late double temperature;
|
||||
int? windDirection;
|
||||
double? windSpeed;
|
||||
int? cloudCover;
|
||||
double? dewPoint;
|
||||
int? relativeHumidity;
|
||||
int? visibility;
|
||||
int? windGustDirection;
|
||||
double? windGustSpeed;
|
||||
String? condition;
|
||||
String? icon;
|
||||
|
||||
HourlyWeatherModel();
|
||||
|
||||
HourlyWeatherModel.fromJson(Map<String, dynamic> json) {
|
||||
sourceId = json['source_id'].toString();
|
||||
precipitation = json['precipitation'];
|
||||
pressure = json['pressure'];
|
||||
sunshine = json['sundshine'];
|
||||
temperature = json['temperature'];
|
||||
windDirection = json['wind_direction'];
|
||||
windSpeed = json['wind_speed'];
|
||||
cloudCover = json['cloud_cover'];
|
||||
dewPoint = json['dew_point'];
|
||||
relativeHumidity = json['relative_humidity'];
|
||||
visibility = json['visibility'];
|
||||
windGustDirection = json['wind_gust_direction'];
|
||||
windGustSpeed = json['wind_gust_speed'];
|
||||
condition = json['condition'];
|
||||
icon = json['icon'];
|
||||
timestamp = DateTime.parse(json['timestamp']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user