18 lines
593 B
Dart
18 lines
593 B
Dart
import 'dart:convert';
|
|
import 'package:http/http.dart' as http;
|
|
import 'package:wetter/models/daily_weather_model.dart';
|
|
|
|
class BrightSkyAPI {
|
|
static Future<DailyWeatherModel> fetchForecast() async {
|
|
final response = await http.get(
|
|
Uri.parse(
|
|
'https://api.brightsky.dev/weather?lat=53.43&lon=20&date=2022-08-30&tz=Europe/Berlin'),
|
|
headers: {"Accept": "application/json"});
|
|
if (response.statusCode == 200) {
|
|
return DailyWeatherModel.fromJson(jsonDecode(response.body));
|
|
} else {
|
|
throw Exception('Failed to load weather data');
|
|
}
|
|
}
|
|
}
|