Tab bar to scroll different location

This commit is contained in:
Konstantin Kollar
2022-09-02 22:38:46 +02:00
parent 1b4b82369b
commit 399a99346b
5 changed files with 174 additions and 129 deletions
+5 -4
View File
@@ -3,11 +3,12 @@ import 'package:http/http.dart' as http;
import 'package:wetter/models/daily_weather_model.dart';
class BrightSkyAPI {
static Future<DailyWeatherModel> fetchForecastOfSingleDay(DateTime d) async {
static Future<DailyWeatherModel> fetchForecastOfSingleDay(
DateTime d, double lat, double lon) async {
String dt = "${d.year}-${d.month}-${d.day}";
final response = await http.get(
Uri.parse(
'https://api.brightsky.dev/weather?lat=53.43&lon=10&date=$dt&tz=Europe/Berlin'),
'https://api.brightsky.dev/weather?lat=$lat&lon=$lon&date=$dt&tz=Europe/Berlin'),
headers: {"Accept": "application/json"});
if (response.statusCode == 200) {
return DailyWeatherModel.fromJson(jsonDecode(response.body));
@@ -17,13 +18,13 @@ class BrightSkyAPI {
}
static Future<List<DailyWeatherModel>> fetchForecastForTimeRange(
DateTime from, int noOfDays) async {
DateTime from, int noOfDays, double lat, double lon) async {
DateTime until = from.add(Duration(days: noOfDays));
String fromDay = "${from.year}-${from.month}-${from.day}";
String untilDay = "${until.year}-${until.month}-${until.day}";
final response = await http.get(
Uri.parse(
'https://api.brightsky.dev/weather?lat=53.43&lon=10&date=$fromDay&last_date=$untilDay&tz=Europe/Berlin'),
'https://api.brightsky.dev/weather?lat=$lat&lon=$lon&date=$fromDay&last_date=$untilDay&tz=Europe/Berlin'),
headers: {"Accept": "application/json"});
final Map<String, dynamic> responseAsJson = jsonDecode(response.body);
if (response.statusCode == 200) {