open weather map http get
// include http dependency in pubspec.yaml
/*
* https://pub.dev/packages/http/install
* */
dependencies:
http: ^0.13.1
// import http in the dart file where you will be interacting with it
import 'package:http/http.dart' as http;
// use http
/*
* you will get your {key} from https://openweathermap.org/
write the key without the braces {}
if you run into any Uri issues: https://stackoverflow.com/questions/55995791/how-can-i-resolve-the-argument-type-string-cant-be-assigned-to-the-parameter
* */
String url =
'https://api.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid={key}';
Future<String> getData() async {
var response =
await http.get(Uri.parse(url), headers: {"Accept": "application/json"});
print(response.body);
return "Success";
}