Last active
September 8, 2022 11:58
-
-
Save austinevick/f97f96909d4e23bb9ed32c7686645855 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final weatherServiceProvider = Provider((ref) => WeatherServiceImpl()); | |
abstract class WeatherService { | |
Future getWeather(WeatherModel model); | |
} | |
class WeatherServiceImpl extends WeatherService { | |
final _client = Client(); | |
const baseUrl = "https://api.openweathermap.org/data/"; | |
const version = '2.5/'; | |
const apikey = ''; | |
@override | |
Future<WeatherResponseModel> getWeather(WeatherModel model) async { | |
final response = await _client.get(Uri.parse( | |
"$baseUrl${version}forecast?lat=${model.latitude}&lon=${model.longitude}&appid=$apikey")); | |
final data = jsonDecode(response.body); | |
print(data); | |
return WeatherResponseModel.fromJson(data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment