Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:dio/dio.dart';
- import 'package:ementodo/core/resources/data_state.dart';
- import 'package:ementodo/features/feature_weather/data/data_sources/remote/api_provider.dart';
- import 'package:ementodo/features/feature_weather/data/models/current_city_model.dart';
- import 'package:ementodo/features/feature_weather/domain/entities/current_city_entity.dart';
- import 'package:ementodo/features/feature_weather/domain/repositories/weather_repository.dart';
- class WeatherRepositoryImpl extends WeatherRepository {
- ApiProvider apiProvider;
- WeatherRepositoryImpl(this.apiProvider);
- @override
- Future<DataState<CurrentCityEntity>> fetchCurrentWeatherData(String cityName)
- async {
- try {
- Response response = await apiProvider.callCurrentWeather(cityName);
- if (response.statusCode == 200) {
- CurrentCityEntity currentCityEntity =
- CurrentCityModel.fromJson(response.data);
- return DataSuccess(currentCityEntity);
- } else {
- DataField("Something went wrong. Try again...");
- }
- } catch (e) {
- DataField("Please check your connection...");
- }
- return DataField("Something went wrong. Try again...");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement