Tab bar to scroll different location
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user