20 lines
514 B
Dart
20 lines
514 B
Dart
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);
|
|
}
|
|
}
|