Created
October 17, 2019 06:09
-
-
Save McLarenCollege/be6dc67938cac2713902a298aa5953ce 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
import 'dart:convert'; | |
import 'package:http/http.dart'; | |
class NetworkHelper { | |
String url; | |
final String api_key = '4f7b32dc58f4ac156caec77d106358f8'; | |
NetworkHelper(this.url); | |
// 'https://api.openweathermap.org/daa/2.5/weather?lat=${location.latitude}&lon=${location.longitude}&appid=$api_key' | |
Future<Map> fetchWeatherInfo() async { | |
Map weatherMap; | |
Response response = await get(url); | |
print(response.statusCode); | |
if (response.statusCode == 200) { | |
weatherMap = jsonDecode(response.body); | |
} | |
return weatherMap; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment