Kodax

تطبيق طقس — تحدي Dart

منطق تطبيق الطقس: kelvinToCelsius (ك - 273.15)، و kelvinToFahrenheit، و parseWeatherJson لقراءة name و main.temp و weather[0].description و main.humidity، و getWeatherAdvice حسب الحرارة. (يُفحص الكود بنيوياً.)

// نموذج بيانات الطقس
class WeatherData {
  final String city;
  final double tempKelvin;
  final String description;
  final int humidity;
  WeatherData({required this.city, required this.tempKelvin, required this.description, required this.humidity});
}

// تحويل من كلفن إلى مئوي
double kelvinToCelsius(double kelvin) {
  // أكمل
  return 0.0;
}

// تحويل من كلفن إلى فهرنهايت
double kelvinToFahrenheit(double kelvin) {
  // أكمل
  return 0.0;
}

// تحويل بيانات JSON إلى WeatherData
WeatherData parseWeatherJson(Map<String, dynamic> json) {
  // أكمل: استخرج البيانات من JSON
  return WeatherData(city: '', tempKelvin: 0, description: '', humidity: 0);
}

// وصف حالة الطقس
String getWeatherAdvice(double tempCelsius) {
  // أكمل: أرجع نصيحة بناءً على درجة الحرارة
  return '';
}

حل هذا التحدي يرتبط بفتح دورة «Flutter المتقدم» بحسابك.

ابدأ الحل