mirror of
https://github.com/darkmoonight/Rain.git
synced 2025-06-28 20:19:58 +00:00
api
This commit is contained in:
parent
dca770e9e3
commit
9a2b48ed2d
8 changed files with 278 additions and 312 deletions
|
@ -2,8 +2,8 @@ import 'package:dio/dio.dart';
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rain/app/api/city.dart';
|
||||
import 'package:rain/app/api/daily.dart';
|
||||
import 'package:rain/app/api/hourly.dart';
|
||||
import 'package:rain/app/api/weather.dart';
|
||||
|
||||
import 'package:rain/app/data/weather.dart';
|
||||
import 'package:rain/main.dart';
|
||||
|
||||
|
@ -13,66 +13,53 @@ class WeatherAPI {
|
|||
final Dio dioLocation = Dio();
|
||||
|
||||
Future<MainWeatherCache> getWeatherData(double? lat, double? lon) async {
|
||||
String baseUrlHourly =
|
||||
'latitude=$lat&longitude=$lon&hourly=temperature_2m,relativehumidity_2m,apparent_temperature,precipitation,rain,weathercode,surface_pressure,visibility,evapotranspiration,windspeed_10m,winddirection_10m,windgusts_10m,cloudcover,uv_index&timezone=auto&forecast_days=7';
|
||||
String urlHourly;
|
||||
String url =
|
||||
'latitude=$lat&longitude=$lon&hourly=temperature_2m,relativehumidity_2m,apparent_temperature,precipitation,rain,weathercode,surface_pressure,visibility,evapotranspiration,windspeed_10m,winddirection_10m,windgusts_10m,cloudcover,uv_index&daily=weathercode,temperature_2m_max,temperature_2m_min,apparent_temperature_max,apparent_temperature_min,sunrise,sunset,precipitation_sum,precipitation_probability_max,windspeed_10m_max,windgusts_10m_max,uv_index_max,rain_sum,winddirection_10m_dominant&forecast_days=12&timezone=auto';
|
||||
String urlWeather;
|
||||
settings.measurements == 'imperial' && settings.degrees == 'fahrenheit'
|
||||
? urlHourly =
|
||||
'$baseUrlHourly&temperature_unit=fahrenheit&windspeed_unit=mph&precipitation_unit=inch'
|
||||
? urlWeather =
|
||||
'$url&temperature_unit=fahrenheit&windspeed_unit=mph&precipitation_unit=inch'
|
||||
: settings.measurements == 'imperial'
|
||||
? urlHourly =
|
||||
'$baseUrlHourly&windspeed_unit=mph&precipitation_unit=inch'
|
||||
? urlWeather = '$url&windspeed_unit=mph&precipitation_unit=inch'
|
||||
: settings.degrees == 'fahrenheit'
|
||||
? urlHourly = '$baseUrlHourly&temperature_unit=fahrenheit'
|
||||
: urlHourly = baseUrlHourly;
|
||||
|
||||
String baseUrlDaily =
|
||||
'latitude=$lat&longitude=$lon&daily=weathercode,temperature_2m_max,temperature_2m_min,apparent_temperature_max,apparent_temperature_min,sunrise,sunset,precipitation_sum,precipitation_probability_max,windspeed_10m_max,windgusts_10m_max,uv_index_max,rain_sum,winddirection_10m_dominant&forecast_days=12&timezone=auto';
|
||||
String urlDaily;
|
||||
settings.degrees == 'fahrenheit'
|
||||
? urlDaily = '$baseUrlDaily&temperature_unit=fahrenheit'
|
||||
: urlDaily = baseUrlDaily;
|
||||
? urlWeather = '$url&temperature_unit=fahrenheit'
|
||||
: urlWeather = url;
|
||||
try {
|
||||
Response responseHourly = await dio.get(urlHourly);
|
||||
Response responseDaily = await dio.get(urlDaily);
|
||||
WeatherHourlyApi weatherDataHourly =
|
||||
WeatherHourlyApi.fromJson(responseHourly.data);
|
||||
WeatherDailyApi weatherDataDaily =
|
||||
WeatherDailyApi.fromJson(responseDaily.data);
|
||||
Response response = await dio.get(urlWeather);
|
||||
WeatherDataApi weatherData = WeatherDataApi.fromJson(response.data);
|
||||
return MainWeatherCache(
|
||||
time: weatherDataHourly.hourly.time,
|
||||
temperature2M: weatherDataHourly.hourly.temperature2M,
|
||||
relativehumidity2M: weatherDataHourly.hourly.relativehumidity2M,
|
||||
apparentTemperature: weatherDataHourly.hourly.apparentTemperature,
|
||||
precipitation: weatherDataHourly.hourly.precipitation,
|
||||
rain: weatherDataHourly.hourly.rain,
|
||||
weathercode: weatherDataHourly.hourly.weathercode,
|
||||
surfacePressure: weatherDataHourly.hourly.surfacePressure,
|
||||
visibility: weatherDataHourly.hourly.visibility,
|
||||
evapotranspiration: weatherDataHourly.hourly.evapotranspiration,
|
||||
windspeed10M: weatherDataHourly.hourly.windspeed10M,
|
||||
winddirection10M: weatherDataHourly.hourly.winddirection10M,
|
||||
windgusts10M: weatherDataHourly.hourly.windgusts10M,
|
||||
cloudcover: weatherDataHourly.hourly.cloudcover,
|
||||
uvIndex: weatherDataHourly.hourly.uvIndex,
|
||||
timeDaily: weatherDataDaily.daily.time,
|
||||
weathercodeDaily: weatherDataDaily.daily.weathercode,
|
||||
temperature2MMax: weatherDataDaily.daily.temperature2MMax,
|
||||
temperature2MMin: weatherDataDaily.daily.temperature2MMin,
|
||||
apparentTemperatureMax: weatherDataDaily.daily.apparentTemperatureMax,
|
||||
apparentTemperatureMin: weatherDataDaily.daily.apparentTemperatureMin,
|
||||
sunrise: weatherDataDaily.daily.sunrise,
|
||||
sunset: weatherDataDaily.daily.sunset,
|
||||
precipitationSum: weatherDataDaily.daily.precipitationSum,
|
||||
time: weatherData.hourly.time,
|
||||
temperature2M: weatherData.hourly.temperature2M,
|
||||
relativehumidity2M: weatherData.hourly.relativehumidity2M,
|
||||
apparentTemperature: weatherData.hourly.apparentTemperature,
|
||||
precipitation: weatherData.hourly.precipitation,
|
||||
rain: weatherData.hourly.rain,
|
||||
weathercode: weatherData.hourly.weathercode,
|
||||
surfacePressure: weatherData.hourly.surfacePressure,
|
||||
visibility: weatherData.hourly.visibility,
|
||||
evapotranspiration: weatherData.hourly.evapotranspiration,
|
||||
windspeed10M: weatherData.hourly.windspeed10M,
|
||||
winddirection10M: weatherData.hourly.winddirection10M,
|
||||
windgusts10M: weatherData.hourly.windgusts10M,
|
||||
cloudcover: weatherData.hourly.cloudcover,
|
||||
uvIndex: weatherData.hourly.uvIndex,
|
||||
timeDaily: weatherData.daily.time,
|
||||
weathercodeDaily: weatherData.daily.weathercode,
|
||||
temperature2MMax: weatherData.daily.temperature2MMax,
|
||||
temperature2MMin: weatherData.daily.temperature2MMin,
|
||||
apparentTemperatureMax: weatherData.daily.apparentTemperatureMax,
|
||||
apparentTemperatureMin: weatherData.daily.apparentTemperatureMin,
|
||||
sunrise: weatherData.daily.sunrise,
|
||||
sunset: weatherData.daily.sunset,
|
||||
precipitationSum: weatherData.daily.precipitationSum,
|
||||
precipitationProbabilityMax:
|
||||
weatherDataDaily.daily.precipitationProbabilityMax,
|
||||
windspeed10MMax: weatherDataDaily.daily.windspeed10MMax,
|
||||
windgusts10MMax: weatherDataDaily.daily.windgusts10MMax,
|
||||
uvIndexMax: weatherDataDaily.daily.uvIndexMax,
|
||||
rainSum: weatherDataDaily.daily.rainSum,
|
||||
winddirection10MDominant:
|
||||
weatherDataDaily.daily.winddirection10MDominant,
|
||||
timezone: weatherDataHourly.timezone,
|
||||
weatherData.daily.precipitationProbabilityMax,
|
||||
windspeed10MMax: weatherData.daily.windspeed10MMax,
|
||||
windgusts10MMax: weatherData.daily.windgusts10MMax,
|
||||
uvIndexMax: weatherData.daily.uvIndexMax,
|
||||
rainSum: weatherData.daily.rainSum,
|
||||
winddirection10MDominant: weatherData.daily.winddirection10MDominant,
|
||||
timezone: weatherData.timezone,
|
||||
timestamp: DateTime.now(),
|
||||
);
|
||||
} on DioException catch (e) {
|
||||
|
@ -111,65 +98,52 @@ class WeatherAPI {
|
|||
|
||||
Future<WeatherCard> getWeatherCard(double? lat, double? lon, String city,
|
||||
String district, String timezone) async {
|
||||
String baseUrlHourly =
|
||||
'latitude=$lat&longitude=$lon&hourly=temperature_2m,relativehumidity_2m,apparent_temperature,precipitation,rain,weathercode,surface_pressure,visibility,evapotranspiration,windspeed_10m,winddirection_10m,windgusts_10m,cloudcover,uv_index&timezone=auto&forecast_days=7';
|
||||
String urlHourly;
|
||||
String url =
|
||||
'latitude=$lat&longitude=$lon&hourly=temperature_2m,relativehumidity_2m,apparent_temperature,precipitation,rain,weathercode,surface_pressure,visibility,evapotranspiration,windspeed_10m,winddirection_10m,windgusts_10m,cloudcover,uv_index&daily=weathercode,temperature_2m_max,temperature_2m_min,apparent_temperature_max,apparent_temperature_min,sunrise,sunset,precipitation_sum,precipitation_probability_max,windspeed_10m_max,windgusts_10m_max,uv_index_max,rain_sum,winddirection_10m_dominant&forecast_days=12&timezone=auto';
|
||||
String urlWeather;
|
||||
settings.measurements == 'imperial' && settings.degrees == 'fahrenheit'
|
||||
? urlHourly =
|
||||
'$baseUrlHourly&temperature_unit=fahrenheit&windspeed_unit=mph&precipitation_unit=inch'
|
||||
? urlWeather =
|
||||
'$url&temperature_unit=fahrenheit&windspeed_unit=mph&precipitation_unit=inch'
|
||||
: settings.measurements == 'imperial'
|
||||
? urlHourly =
|
||||
'$baseUrlHourly&windspeed_unit=mph&precipitation_unit=inch'
|
||||
? urlWeather = '$url&windspeed_unit=mph&precipitation_unit=inch'
|
||||
: settings.degrees == 'fahrenheit'
|
||||
? urlHourly = '$baseUrlHourly&temperature_unit=fahrenheit'
|
||||
: urlHourly = baseUrlHourly;
|
||||
|
||||
String baseUrlDaily =
|
||||
'latitude=$lat&longitude=$lon&daily=weathercode,temperature_2m_max,temperature_2m_min,apparent_temperature_max,apparent_temperature_min,sunrise,sunset,precipitation_sum,precipitation_probability_max,windspeed_10m_max,windgusts_10m_max,uv_index_max,rain_sum,winddirection_10m_dominant&forecast_days=12&timezone=auto';
|
||||
String urlDaily;
|
||||
settings.degrees == 'fahrenheit'
|
||||
? urlDaily = '$baseUrlDaily&temperature_unit=fahrenheit'
|
||||
: urlDaily = baseUrlDaily;
|
||||
? urlWeather = '$url&temperature_unit=fahrenheit'
|
||||
: urlWeather = url;
|
||||
try {
|
||||
Response responseHourly = await dio.get(urlHourly);
|
||||
Response responseDaily = await dio.get(urlDaily);
|
||||
WeatherHourlyApi weatherDataHourly =
|
||||
WeatherHourlyApi.fromJson(responseHourly.data);
|
||||
WeatherDailyApi weatherDataDaily =
|
||||
WeatherDailyApi.fromJson(responseDaily.data);
|
||||
Response response = await dio.get(urlWeather);
|
||||
WeatherDataApi weatherData = WeatherDataApi.fromJson(response.data);
|
||||
return WeatherCard(
|
||||
time: weatherDataHourly.hourly.time,
|
||||
temperature2M: weatherDataHourly.hourly.temperature2M,
|
||||
relativehumidity2M: weatherDataHourly.hourly.relativehumidity2M,
|
||||
apparentTemperature: weatherDataHourly.hourly.apparentTemperature,
|
||||
precipitation: weatherDataHourly.hourly.precipitation,
|
||||
rain: weatherDataHourly.hourly.rain,
|
||||
weathercode: weatherDataHourly.hourly.weathercode,
|
||||
surfacePressure: weatherDataHourly.hourly.surfacePressure,
|
||||
visibility: weatherDataHourly.hourly.visibility,
|
||||
evapotranspiration: weatherDataHourly.hourly.evapotranspiration,
|
||||
windspeed10M: weatherDataHourly.hourly.windspeed10M,
|
||||
winddirection10M: weatherDataHourly.hourly.winddirection10M,
|
||||
windgusts10M: weatherDataHourly.hourly.windgusts10M,
|
||||
cloudcover: weatherDataHourly.hourly.cloudcover,
|
||||
uvIndex: weatherDataHourly.hourly.uvIndex,
|
||||
timeDaily: weatherDataDaily.daily.time,
|
||||
weathercodeDaily: weatherDataDaily.daily.weathercode,
|
||||
temperature2MMax: weatherDataDaily.daily.temperature2MMax,
|
||||
temperature2MMin: weatherDataDaily.daily.temperature2MMin,
|
||||
apparentTemperatureMax: weatherDataDaily.daily.apparentTemperatureMax,
|
||||
apparentTemperatureMin: weatherDataDaily.daily.apparentTemperatureMin,
|
||||
sunrise: weatherDataDaily.daily.sunrise,
|
||||
sunset: weatherDataDaily.daily.sunset,
|
||||
precipitationSum: weatherDataDaily.daily.precipitationSum,
|
||||
time: weatherData.hourly.time,
|
||||
temperature2M: weatherData.hourly.temperature2M,
|
||||
relativehumidity2M: weatherData.hourly.relativehumidity2M,
|
||||
apparentTemperature: weatherData.hourly.apparentTemperature,
|
||||
precipitation: weatherData.hourly.precipitation,
|
||||
rain: weatherData.hourly.rain,
|
||||
weathercode: weatherData.hourly.weathercode,
|
||||
surfacePressure: weatherData.hourly.surfacePressure,
|
||||
visibility: weatherData.hourly.visibility,
|
||||
evapotranspiration: weatherData.hourly.evapotranspiration,
|
||||
windspeed10M: weatherData.hourly.windspeed10M,
|
||||
winddirection10M: weatherData.hourly.winddirection10M,
|
||||
windgusts10M: weatherData.hourly.windgusts10M,
|
||||
cloudcover: weatherData.hourly.cloudcover,
|
||||
uvIndex: weatherData.hourly.uvIndex,
|
||||
timeDaily: weatherData.daily.time,
|
||||
weathercodeDaily: weatherData.daily.weathercode,
|
||||
temperature2MMax: weatherData.daily.temperature2MMax,
|
||||
temperature2MMin: weatherData.daily.temperature2MMin,
|
||||
apparentTemperatureMax: weatherData.daily.apparentTemperatureMax,
|
||||
apparentTemperatureMin: weatherData.daily.apparentTemperatureMin,
|
||||
sunrise: weatherData.daily.sunrise,
|
||||
sunset: weatherData.daily.sunset,
|
||||
precipitationSum: weatherData.daily.precipitationSum,
|
||||
precipitationProbabilityMax:
|
||||
weatherDataDaily.daily.precipitationProbabilityMax,
|
||||
windspeed10MMax: weatherDataDaily.daily.windspeed10MMax,
|
||||
windgusts10MMax: weatherDataDaily.daily.windgusts10MMax,
|
||||
uvIndexMax: weatherDataDaily.daily.uvIndexMax,
|
||||
rainSum: weatherDataDaily.daily.rainSum,
|
||||
winddirection10MDominant:
|
||||
weatherDataDaily.daily.winddirection10MDominant,
|
||||
weatherData.daily.precipitationProbabilityMax,
|
||||
windspeed10MMax: weatherData.daily.windspeed10MMax,
|
||||
windgusts10MMax: weatherData.daily.windgusts10MMax,
|
||||
uvIndexMax: weatherData.daily.uvIndexMax,
|
||||
rainSum: weatherData.daily.rainSum,
|
||||
winddirection10MDominant: weatherData.daily.winddirection10MDominant,
|
||||
lat: lat,
|
||||
lon: lon,
|
||||
city: city,
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
class WeatherDailyApi {
|
||||
WeatherDailyApi({
|
||||
required this.daily,
|
||||
});
|
||||
|
||||
Daily daily;
|
||||
|
||||
factory WeatherDailyApi.fromJson(Map<String, dynamic> json) =>
|
||||
WeatherDailyApi(
|
||||
daily: Daily.fromJson(json['daily']),
|
||||
);
|
||||
}
|
||||
|
||||
class Daily {
|
||||
Daily({
|
||||
this.time,
|
||||
this.weathercode,
|
||||
this.temperature2MMax,
|
||||
this.temperature2MMin,
|
||||
this.apparentTemperatureMax,
|
||||
this.apparentTemperatureMin,
|
||||
this.sunrise,
|
||||
this.sunset,
|
||||
this.precipitationSum,
|
||||
this.precipitationProbabilityMax,
|
||||
this.windspeed10MMax,
|
||||
this.windgusts10MMax,
|
||||
this.uvIndexMax,
|
||||
this.rainSum,
|
||||
this.winddirection10MDominant,
|
||||
});
|
||||
|
||||
List<DateTime>? time;
|
||||
List<int?>? weathercode;
|
||||
List<double?>? temperature2MMax;
|
||||
List<double?>? temperature2MMin;
|
||||
List<double?>? apparentTemperatureMax;
|
||||
List<double?>? apparentTemperatureMin;
|
||||
List<String>? sunrise;
|
||||
List<String>? sunset;
|
||||
List<double?>? precipitationSum;
|
||||
List<int?>? precipitationProbabilityMax;
|
||||
List<double?>? windspeed10MMax;
|
||||
List<double?>? windgusts10MMax;
|
||||
List<double?>? uvIndexMax;
|
||||
List<double?>? rainSum;
|
||||
List<int?>? winddirection10MDominant;
|
||||
|
||||
factory Daily.fromJson(Map<String, dynamic> json) => Daily(
|
||||
time: List<DateTime>.from(json['time'].map((x) => DateTime.parse(x))),
|
||||
weathercode: List<int?>.from(json['weathercode'].map((x) => x)),
|
||||
temperature2MMax:
|
||||
List<double?>.from(json['temperature_2m_max'].map((x) => x)),
|
||||
temperature2MMin:
|
||||
List<double?>.from(json['temperature_2m_min'].map((x) => x)),
|
||||
apparentTemperatureMax:
|
||||
List<double?>.from(json['apparent_temperature_max'].map((x) => x)),
|
||||
apparentTemperatureMin:
|
||||
List<double?>.from(json['apparent_temperature_min'].map((x) => x)),
|
||||
sunrise: List<String>.from(json['sunrise'].map((x) => x)),
|
||||
sunset: List<String>.from(json['sunset'].map((x) => x)),
|
||||
precipitationSum:
|
||||
List<double?>.from(json['precipitation_sum'].map((x) => x)),
|
||||
precipitationProbabilityMax: List<int?>.from(
|
||||
json['precipitation_probability_max'].map((x) => x)),
|
||||
windspeed10MMax:
|
||||
List<double?>.from(json['windspeed_10m_max'].map((x) => x)),
|
||||
windgusts10MMax:
|
||||
List<double?>.from(json['windgusts_10m_max'].map((x) => x)),
|
||||
uvIndexMax: List<double?>.from(json['uv_index_max'].map((x) => x)),
|
||||
rainSum: List<double?>.from(json['rain_sum'].map((x) => x)),
|
||||
winddirection10MDominant:
|
||||
List<int?>.from(json['winddirection_10m_dominant'].map((x) => x)),
|
||||
);
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
class WeatherHourlyApi {
|
||||
WeatherHourlyApi({
|
||||
required this.hourly,
|
||||
required this.timezone,
|
||||
});
|
||||
|
||||
Hourly hourly;
|
||||
String timezone;
|
||||
|
||||
factory WeatherHourlyApi.fromJson(Map<String, dynamic> json) =>
|
||||
WeatherHourlyApi(
|
||||
hourly: Hourly.fromJson(json['hourly']),
|
||||
timezone: json['timezone'],
|
||||
);
|
||||
}
|
||||
|
||||
class Hourly {
|
||||
Hourly({
|
||||
this.time,
|
||||
this.temperature2M,
|
||||
this.relativehumidity2M,
|
||||
this.apparentTemperature,
|
||||
this.precipitation,
|
||||
this.rain,
|
||||
this.weathercode,
|
||||
this.surfacePressure,
|
||||
this.visibility,
|
||||
this.evapotranspiration,
|
||||
this.windspeed10M,
|
||||
this.winddirection10M,
|
||||
this.windgusts10M,
|
||||
this.cloudcover,
|
||||
this.uvIndex,
|
||||
});
|
||||
|
||||
List<String>? time;
|
||||
List<int>? weathercode;
|
||||
List<double>? temperature2M;
|
||||
List<double?>? apparentTemperature;
|
||||
List<double?>? precipitation;
|
||||
List<double?>? rain;
|
||||
List<int?>? relativehumidity2M;
|
||||
List<double?>? surfacePressure;
|
||||
List<double?>? visibility;
|
||||
List<double?>? evapotranspiration;
|
||||
List<double?>? windspeed10M;
|
||||
List<int?>? winddirection10M;
|
||||
List<double?>? windgusts10M;
|
||||
List<int?>? cloudcover;
|
||||
List<double?>? uvIndex;
|
||||
|
||||
factory Hourly.fromJson(Map<String, dynamic> json) => Hourly(
|
||||
time: List<String>.from(json['time'].map((x) => x)),
|
||||
weathercode: List<int>.from(json['weathercode'].map((x) => x)),
|
||||
temperature2M: List<double>.from(json['temperature_2m'].map((x) => x)),
|
||||
apparentTemperature:
|
||||
List<double?>.from(json['apparent_temperature'].map((x) => x)),
|
||||
relativehumidity2M:
|
||||
List<int?>.from(json['relativehumidity_2m'].map((x) => x)),
|
||||
precipitation: List<double>.from(json['precipitation'].map((x) => x)),
|
||||
rain: List<double?>.from(json['rain'].map((x) => x)),
|
||||
surfacePressure:
|
||||
List<double?>.from(json['surface_pressure'].map((x) => x)),
|
||||
visibility: List<double?>.from(json['visibility'].map((x) => x)),
|
||||
evapotranspiration:
|
||||
List<double?>.from(json['evapotranspiration'].map((x) => x)),
|
||||
windspeed10M: List<double?>.from(json['windspeed_10m'].map((x) => x)),
|
||||
winddirection10M:
|
||||
List<int?>.from(json['winddirection_10m'].map((x) => x)),
|
||||
windgusts10M: List<double?>.from(json['windgusts_10m'].map((x) => x)),
|
||||
cloudcover: List<int?>.from(json['cloudcover'].map((x) => x)),
|
||||
uvIndex: List<double?>.from(json['uv_index'].map((x) => x)),
|
||||
);
|
||||
}
|
139
lib/app/api/weather.dart
Normal file
139
lib/app/api/weather.dart
Normal file
|
@ -0,0 +1,139 @@
|
|||
class WeatherDataApi {
|
||||
Hourly hourly;
|
||||
Daily daily;
|
||||
String timezone;
|
||||
|
||||
WeatherDataApi({
|
||||
required this.hourly,
|
||||
required this.daily,
|
||||
required this.timezone,
|
||||
});
|
||||
|
||||
factory WeatherDataApi.fromJson(Map<String, dynamic> json) => WeatherDataApi(
|
||||
hourly: Hourly.fromJson(json["hourly"]),
|
||||
daily: Daily.fromJson(json["daily"]),
|
||||
timezone: json['timezone'],
|
||||
);
|
||||
}
|
||||
|
||||
class Hourly {
|
||||
List<String>? time;
|
||||
List<int>? weathercode;
|
||||
List<double>? temperature2M;
|
||||
List<double?>? apparentTemperature;
|
||||
List<double?>? precipitation;
|
||||
List<double?>? rain;
|
||||
List<int?>? relativehumidity2M;
|
||||
List<double?>? surfacePressure;
|
||||
List<double?>? visibility;
|
||||
List<double?>? evapotranspiration;
|
||||
List<double?>? windspeed10M;
|
||||
List<int?>? winddirection10M;
|
||||
List<double?>? windgusts10M;
|
||||
List<int?>? cloudcover;
|
||||
List<double?>? uvIndex;
|
||||
|
||||
Hourly({
|
||||
this.time,
|
||||
this.temperature2M,
|
||||
this.relativehumidity2M,
|
||||
this.apparentTemperature,
|
||||
this.precipitation,
|
||||
this.rain,
|
||||
this.weathercode,
|
||||
this.surfacePressure,
|
||||
this.visibility,
|
||||
this.evapotranspiration,
|
||||
this.windspeed10M,
|
||||
this.winddirection10M,
|
||||
this.windgusts10M,
|
||||
this.cloudcover,
|
||||
this.uvIndex,
|
||||
});
|
||||
|
||||
factory Hourly.fromJson(Map<String, dynamic> json) => Hourly(
|
||||
time: List<String>.from(json['time'].map((x) => x)),
|
||||
weathercode: List<int>.from(json['weathercode'].map((x) => x)),
|
||||
temperature2M: List<double>.from(json['temperature_2m'].map((x) => x)),
|
||||
apparentTemperature:
|
||||
List<double?>.from(json['apparent_temperature'].map((x) => x)),
|
||||
relativehumidity2M:
|
||||
List<int?>.from(json['relativehumidity_2m'].map((x) => x)),
|
||||
precipitation: List<double>.from(json['precipitation'].map((x) => x)),
|
||||
rain: List<double?>.from(json['rain'].map((x) => x)),
|
||||
surfacePressure:
|
||||
List<double?>.from(json['surface_pressure'].map((x) => x)),
|
||||
visibility: List<double?>.from(json['visibility'].map((x) => x)),
|
||||
evapotranspiration:
|
||||
List<double?>.from(json['evapotranspiration'].map((x) => x)),
|
||||
windspeed10M: List<double?>.from(json['windspeed_10m'].map((x) => x)),
|
||||
winddirection10M:
|
||||
List<int?>.from(json['winddirection_10m'].map((x) => x)),
|
||||
windgusts10M: List<double?>.from(json['windgusts_10m'].map((x) => x)),
|
||||
cloudcover: List<int?>.from(json['cloudcover'].map((x) => x)),
|
||||
uvIndex: List<double?>.from(json['uv_index'].map((x) => x)),
|
||||
);
|
||||
}
|
||||
|
||||
class Daily {
|
||||
List<DateTime>? time;
|
||||
List<int?>? weathercode;
|
||||
List<double?>? temperature2MMax;
|
||||
List<double?>? temperature2MMin;
|
||||
List<double?>? apparentTemperatureMax;
|
||||
List<double?>? apparentTemperatureMin;
|
||||
List<String>? sunrise;
|
||||
List<String>? sunset;
|
||||
List<double?>? precipitationSum;
|
||||
List<int?>? precipitationProbabilityMax;
|
||||
List<double?>? windspeed10MMax;
|
||||
List<double?>? windgusts10MMax;
|
||||
List<double?>? uvIndexMax;
|
||||
List<double?>? rainSum;
|
||||
List<int?>? winddirection10MDominant;
|
||||
|
||||
Daily({
|
||||
this.time,
|
||||
this.weathercode,
|
||||
this.temperature2MMax,
|
||||
this.temperature2MMin,
|
||||
this.apparentTemperatureMax,
|
||||
this.apparentTemperatureMin,
|
||||
this.sunrise,
|
||||
this.sunset,
|
||||
this.precipitationSum,
|
||||
this.precipitationProbabilityMax,
|
||||
this.windspeed10MMax,
|
||||
this.windgusts10MMax,
|
||||
this.uvIndexMax,
|
||||
this.rainSum,
|
||||
this.winddirection10MDominant,
|
||||
});
|
||||
|
||||
factory Daily.fromJson(Map<String, dynamic> json) => Daily(
|
||||
time: List<DateTime>.from(json['time'].map((x) => DateTime.parse(x))),
|
||||
weathercode: List<int?>.from(json['weathercode'].map((x) => x)),
|
||||
temperature2MMax:
|
||||
List<double?>.from(json['temperature_2m_max'].map((x) => x)),
|
||||
temperature2MMin:
|
||||
List<double?>.from(json['temperature_2m_min'].map((x) => x)),
|
||||
apparentTemperatureMax:
|
||||
List<double?>.from(json['apparent_temperature_max'].map((x) => x)),
|
||||
apparentTemperatureMin:
|
||||
List<double?>.from(json['apparent_temperature_min'].map((x) => x)),
|
||||
sunrise: List<String>.from(json['sunrise'].map((x) => x)),
|
||||
sunset: List<String>.from(json['sunset'].map((x) => x)),
|
||||
precipitationSum:
|
||||
List<double?>.from(json['precipitation_sum'].map((x) => x)),
|
||||
precipitationProbabilityMax: List<int?>.from(
|
||||
json['precipitation_probability_max'].map((x) => x)),
|
||||
windspeed10MMax:
|
||||
List<double?>.from(json['windspeed_10m_max'].map((x) => x)),
|
||||
windgusts10MMax:
|
||||
List<double?>.from(json['windgusts_10m_max'].map((x) => x)),
|
||||
uvIndexMax: List<double?>.from(json['uv_index_max'].map((x) => x)),
|
||||
rainSum: List<double?>.from(json['rain_sum'].map((x) => x)),
|
||||
winddirection10MDominant:
|
||||
List<int?>.from(json['winddirection_10m_dominant'].map((x) => x)),
|
||||
);
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:iconsax/iconsax.dart';
|
||||
import 'package:rain/app/api/api.dart';
|
||||
|
@ -62,6 +63,13 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
SystemUiOverlayStyle(
|
||||
systemNavigationBarColor:
|
||||
context.theme.navigationBarTheme.backgroundColor,
|
||||
),
|
||||
);
|
||||
|
||||
return DefaultTabController(
|
||||
length: pages.length,
|
||||
child: Scaffold(
|
||||
|
|
|
@ -3,7 +3,6 @@ import 'package:connecteo/connecteo.dart';
|
|||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:dynamic_color/dynamic_color.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_displaymode/flutter_displaymode.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
|
@ -56,11 +55,6 @@ final List appLanguages = [
|
|||
void main() async {
|
||||
final String timeZoneName;
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
systemNavigationBarColor: Colors.black,
|
||||
),
|
||||
);
|
||||
await isarInit();
|
||||
if (Platform.isAndroid) {
|
||||
await setOptimalDisplayMode();
|
||||
|
|
88
pubspec.lock
88
pubspec.lock
|
@ -109,10 +109,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: built_value
|
||||
sha256: "598a2a682e2a7a90f08ba39c0aaa9374c5112340f0a2e275f61b59389543d166"
|
||||
sha256: ff627b645b28fb8bdb69e645f910c2458fd6b65f6585c3a53e0626024897dedf
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "8.6.1"
|
||||
version: "8.6.2"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -149,10 +149,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: code_builder
|
||||
sha256: "4ad01d6e56db961d29661561effde45e519939fdaeb46c351275b182eac70189"
|
||||
sha256: "315a598c7fbe77f22de1c9da7cfd6fd21816312f16ffa124453b4fc679e540f1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.5.0"
|
||||
version: "4.6.0"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -314,18 +314,18 @@ packages:
|
|||
dependency: "direct dev"
|
||||
description:
|
||||
name: flutter_lints
|
||||
sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4"
|
||||
sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
version: "2.0.3"
|
||||
flutter_local_notifications:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_local_notifications
|
||||
sha256: "3cc40fe8c50ab8383f3e053a499f00f975636622ecdc8e20a77418ece3b1e975"
|
||||
sha256: "3002092e5b8ce2f86c3361422e52e6db6776c23ee21e0b2f71b892bf4259ef04"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "15.1.0+1"
|
||||
version: "15.1.1"
|
||||
flutter_local_notifications_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -705,50 +705,50 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
name: path_provider
|
||||
sha256: "909b84830485dbcd0308edf6f7368bc8fd76afa26a270420f34cabea2a6467a0"
|
||||
sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "2.1.1"
|
||||
path_provider_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_android
|
||||
sha256: "5d44fc3314d969b84816b569070d7ace0f1dea04bd94a83f74c4829615d22ad8"
|
||||
sha256: "71c95ee27a9938693fa326b54ae60ae996f35a357acd957c71b2735aee2688c5"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "2.1.1"
|
||||
path_provider_foundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_foundation
|
||||
sha256: "1b744d3d774e5a879bb76d6cd1ecee2ba2c6960c03b1020cd35212f6aa267ac5"
|
||||
sha256: "19314d595120f82aca0ba62787d58dde2cc6b5df7d2f0daf72489e38d1b57f2d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.0"
|
||||
version: "2.3.1"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_linux
|
||||
sha256: ba2b77f0c52a33db09fc8caf85b12df691bf28d983e84cf87ff6d693cfa007b3
|
||||
sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
version: "2.2.1"
|
||||
path_provider_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_platform_interface
|
||||
sha256: bced5679c7df11190e1ddc35f3222c858f328fff85c3942e46e7f5589bf9eb84
|
||||
sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "2.1.1"
|
||||
path_provider_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_windows
|
||||
sha256: ee0e0d164516b90ae1f970bdf29f726f1aa730d7cfc449ecc74c495378b705da
|
||||
sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
version: "2.2.1"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -761,18 +761,18 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: platform
|
||||
sha256: "57c07bf82207aee366dfaa3867b3164e4f03a238a461a11b0e8a3a510d51203d"
|
||||
sha256: ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.1"
|
||||
version: "3.1.2"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: plugin_platform_interface
|
||||
sha256: "43798d895c929056255600343db8f049921cbec94d31ec87f1dc5c16c01935dd"
|
||||
sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.5"
|
||||
version: "2.1.6"
|
||||
pointycastle:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -966,66 +966,66 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
name: url_launcher
|
||||
sha256: "781bd58a1eb16069412365c98597726cd8810ae27435f04b3b4d3a470bacd61e"
|
||||
sha256: "38d8e783681bc342e92dc9799cbe4421d08c4d210a67ee9d61d0f7310491a465"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.12"
|
||||
version: "6.1.13"
|
||||
url_launcher_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_android
|
||||
sha256: "3dd2388cc0c42912eee04434531a26a82512b9cb1827e0214430c9bcbddfe025"
|
||||
sha256: ef7e34951ffa963fb7a65928deeb38d40fb3c5975baf93c1d631341ff7f2650a
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.0.38"
|
||||
version: "6.0.39"
|
||||
url_launcher_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_ios
|
||||
sha256: "9af7ea73259886b92199f9e42c116072f05ff9bea2dcb339ab935dfc957392c2"
|
||||
sha256: "7c65021d5dee51813d652357bc65b8dd4a6177082a9966bc8ba6ee477baa795f"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.4"
|
||||
version: "6.1.5"
|
||||
url_launcher_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_linux
|
||||
sha256: "207f4ddda99b95b4d4868320a352d374b0b7e05eefad95a4a26f57da413443f5"
|
||||
sha256: b651aad005e0cb06a01dbd84b428a301916dc75f0e7ea6165f80057fee2d8e8e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.5"
|
||||
version: "3.0.6"
|
||||
url_launcher_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_macos
|
||||
sha256: "1c4fdc0bfea61a70792ce97157e5cc17260f61abbe4f39354513f39ec6fd73b1"
|
||||
sha256: b55486791f666e62e0e8ff825e58a023fd6b1f71c49926483f1128d3bbd8fe88
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.6"
|
||||
version: "3.0.7"
|
||||
url_launcher_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_platform_interface
|
||||
sha256: bfdfa402f1f3298637d71ca8ecfe840b4696698213d5346e9d12d4ab647ee2ea
|
||||
sha256: "4d0dae953f80dc06fa24c58d0f8381302139c22c2dad301417787ad96f5f73bd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.3"
|
||||
version: "2.1.4"
|
||||
url_launcher_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_web
|
||||
sha256: cc26720eefe98c1b71d85f9dc7ef0cada5132617046369d9dc296b3ecaa5cbb4
|
||||
sha256: ba140138558fcc3eead51a1c42e92a9fb074a1b1149ed3c73e66035b2ccd94f2
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.18"
|
||||
version: "2.0.19"
|
||||
url_launcher_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_windows
|
||||
sha256: "7967065dd2b5fccc18c653b97958fdf839c5478c28e767c61ee879f4e7882422"
|
||||
sha256: "95fef3129dc7cfaba2bc3d5ba2e16063bb561fc6d78e63eee16162bc70029069"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.7"
|
||||
version: "3.0.8"
|
||||
uuid:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -1070,10 +1070,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
sha256: f2add6fa510d3ae152903412227bda57d0d5a8da61d2c39c1fb022c9429a41c0
|
||||
sha256: "9e82a402b7f3d518fb9c02d0e9ae45952df31b9bf34d77baf19da2de03fc2aaa"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.0.6"
|
||||
version: "5.0.7"
|
||||
workmanager:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -1086,10 +1086,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: xdg_directories
|
||||
sha256: f0c26453a2d47aa4c2570c6a033246a3fc62da2fe23c7ffdd0a7495086dc0247
|
||||
sha256: "589ada45ba9e39405c198fe34eb0f607cddb2108527e658136120892beac46d2"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
version: "1.0.3"
|
||||
xml:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -28,9 +28,9 @@ dependencies:
|
|||
google_fonts: ^5.1.0
|
||||
flutter_glow: ^0.3.0
|
||||
time_machine: ^0.9.17
|
||||
url_launcher: ^6.1.12
|
||||
url_launcher: ^6.1.13
|
||||
dynamic_color: ^1.6.6
|
||||
path_provider: ^2.1.0
|
||||
path_provider: ^2.1.1
|
||||
flutter_timezone: ^1.0.7
|
||||
package_info_plus: ^4.1.0
|
||||
connectivity_plus: ^4.0.2
|
||||
|
@ -38,7 +38,7 @@ dependencies:
|
|||
flutter_displaymode: ^0.6.0
|
||||
lat_lng_to_timezone: ^0.2.0
|
||||
scrollable_positioned_list: ^0.3.8
|
||||
flutter_local_notifications: ^15.1.0+1
|
||||
flutter_local_notifications: ^15.1.1
|
||||
|
||||
# Uncomment this for publishing FLOSS variant
|
||||
# dependency_overrides:
|
||||
|
@ -52,7 +52,7 @@ dev_dependencies:
|
|||
flutter_test:
|
||||
sdk: flutter
|
||||
build_runner: ^2.4.6
|
||||
flutter_lints: ^2.0.2
|
||||
flutter_lints: ^2.0.3
|
||||
isar_generator: ^3.1.0+1
|
||||
flutter_native_splash: ^2.3.2
|
||||
flutter_launcher_icons: ^0.13.1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue