class Weather {
final String cityName;
final double temperature;
final String description;
final String icon;
Weather({
required this.cityName,
required this.temperature,
required this.description,
required this.icon,
});
factory Weather.fromJson(Map<String, dynamic> json) {
return Weather(
cityName: json['name'],
temperature: json['main']['temp'].toDouble(),
description: json['weather'][0]['description'],
icon: json['weather'][0]['icon'],
);
}
}
Create a new file lib/services/weather_service.dart
to handle API requests: