Commit 35f7ea7 1 parent a46b228 commit 35f7ea7 Copy full SHA for 35f7ea7
File tree 1 file changed +10
-8
lines changed
1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change 1
1
import 'dart:convert' ;
2
+ import 'dart:ffi' ;
2
3
3
4
import 'package:geolocator/geolocator.dart' ;
4
5
import 'package:condition/condition.dart' ;
@@ -182,11 +183,12 @@ class BodyOfAppState extends State<BodyOfApp> {
182
183
getData ();
183
184
}
184
185
185
- var cloudCover;
186
- var temperature;
187
- String description;
188
- String location;
189
- var neerslag;
186
+ String location = 'nog geen data' ;
187
+ String description = '' ;
188
+ var cloudCover = 0 ;
189
+ var neerslag = 0 ;
190
+ double temperatureValue = 0 ;
191
+ var temperature = 0 ;
190
192
191
193
void getData () async {
192
194
Response response = await get ('https://api.openweathermap.org/data/2.5/find?lat=$latitude &lon=$longitude &cnt=10&appid=$apiKey &units=metric&lang=nl' );
@@ -197,16 +199,16 @@ class BodyOfAppState extends State<BodyOfApp> {
197
199
198
200
var decodedData = jsonDecode (weatherData);
199
201
location = decodedData['list' ][0 ]['name' ];
200
- temperature = decodedData['list' ][0 ]['main' ]['temp' ];
201
- cloudCover = decodedData['list' ][0 ]['clouds' ]['all' ];
202
202
description = decodedData['list' ][0 ]['weather' ][0 ]['description' ];
203
+ cloudCover = decodedData['list' ][0 ]['clouds' ]['all' ];
203
204
neerslag = decodedData['list' ][0 ]['rain' ];
205
+ temperatureValue = decodedData['list' ][0 ]['main' ]['temp' ];
204
206
205
207
if (neerslag == null ) {
206
208
neerslag = 0 ;
207
209
}
208
210
209
- temperature = temperature .round ();
211
+ temperature = temperatureValue .round ();
210
212
print (location);
211
213
print (temperature);
212
214
print (cloudCover);
You can’t perform that action at this time.
0 commit comments