Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Created October 17, 2019 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McLarenCollege/be6dc67938cac2713902a298aa5953ce to your computer and use it in GitHub Desktop.
Save McLarenCollege/be6dc67938cac2713902a298aa5953ce to your computer and use it in GitHub Desktop.
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