Initial commit
This commit is contained in:
19
flutter_app/lib/services/weather_service.dart
Normal file
19
flutter_app/lib/services/weather_service.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import "../config/api_config.dart";
|
||||
import "../models/weather_info.dart";
|
||||
import "api_client.dart";
|
||||
import "mock_data.dart";
|
||||
|
||||
class WeatherService {
|
||||
final ApiClient _client;
|
||||
|
||||
WeatherService(this._client);
|
||||
|
||||
Future<WeatherInfo> fetchWeather({String? city}) async {
|
||||
if (ApiConfig.useMockData) {
|
||||
return MockDataStore.weather;
|
||||
}
|
||||
final query = city != null ? {"q": city} : null;
|
||||
final data = await _client.getMap(ApiConfig.weather, query: query);
|
||||
return WeatherInfo.fromJson(data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user