You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.3 KiB
Dart
71 lines
2.3 KiB
Dart
import 'package:hmg_qline/constants/app_constants.dart';
|
|
|
|
class WeathersWidgetModel {
|
|
int? id;
|
|
String? headline;
|
|
double? maxTemp;
|
|
double? minTemp;
|
|
String? iconPhrase;
|
|
String? forecastDate;
|
|
int? cityID;
|
|
String? forecastDay;
|
|
String? createDateTime;
|
|
double? windSpeed;
|
|
String? windDirection;
|
|
double? windDegrees;
|
|
String? weatherIconPath;
|
|
|
|
WeathersWidgetModel({
|
|
this.id,
|
|
this.headline,
|
|
this.maxTemp,
|
|
this.minTemp,
|
|
this.iconPhrase,
|
|
this.forecastDate,
|
|
this.cityID,
|
|
this.forecastDay,
|
|
this.createDateTime,
|
|
this.windSpeed,
|
|
this.windDirection,
|
|
this.windDegrees,
|
|
this.weatherIconPath,
|
|
});
|
|
|
|
WeathersWidgetModel.fromJson(Map<String, dynamic> json) {
|
|
id = json['id'];
|
|
headline = json['headline'];
|
|
maxTemp = json['maxTemp'] ?? "42.2";
|
|
minTemp = json['minTemp'] ?? "31.7";
|
|
iconPhrase = json['iconPhrase'] ?? "Mostly sunny";
|
|
forecastDate = json['forecastDate'];
|
|
cityID = json['cityID'];
|
|
forecastDay = json['forecastDay'];
|
|
createDateTime = json['createDateTime'];
|
|
windSpeed = json['windSpeed'];
|
|
windDirection = json['windDirection'];
|
|
windDegrees = json['windDegrees'];
|
|
weatherIconPath = getWeatherIconPath(json['iconPhrase']);
|
|
}
|
|
|
|
String getWeatherIconPath(String iconPhrase) {
|
|
if (iconPhrase == "Rain" || iconPhrase == "Showers" || iconPhrase == "ThunderStorms") {
|
|
return AppAssets.rainIcon;
|
|
} else if (iconPhrase == "Hot") {
|
|
return AppAssets.hotIcon;
|
|
} else if (iconPhrase == "Windy") {
|
|
return AppAssets.windIcon;
|
|
} else if (iconPhrase == "Cloudy" || iconPhrase == "Mostly cloudy" || iconPhrase == "Intermittent clouds") {
|
|
return AppAssets.cloudIcon;
|
|
} else if (iconPhrase == "Sunny" || iconPhrase == "Mostly sunny" || iconPhrase == "Partly sunny" || iconPhrase == "Hazy sunshine") {
|
|
return AppAssets.sunnyIcon;
|
|
} else {
|
|
return AppAssets.weatherIcon;
|
|
}
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return 'WeathersWidgetModel{id: $id, headline: $headline, maxTemp: $maxTemp, minTemp: $minTemp, iconPhrase: $iconPhrase, forecastDate: $forecastDate, cityID: $cityID, forecastDay: $forecastDay, createDateTime: $createDateTime, windSpeed: $windSpeed, windDirection: $windDirection, windDegrees: $windDegrees, weatherIconPath: $weatherIconPath}';
|
|
}
|
|
}
|