Skip to content

Commit 35f7ea7

Browse files
committed
Update initial weather values
1 parent a46b228 commit 35f7ea7

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lib/main.dart

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:convert';
2+
import 'dart:ffi';
23

34
import 'package:geolocator/geolocator.dart';
45
import 'package:condition/condition.dart';
@@ -182,11 +183,12 @@ class BodyOfAppState extends State<BodyOfApp> {
182183
getData();
183184
}
184185

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;
190192

191193
void getData() async {
192194
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> {
197199

198200
var decodedData = jsonDecode(weatherData);
199201
location = decodedData['list'][0]['name'];
200-
temperature = decodedData['list'][0]['main']['temp'];
201-
cloudCover = decodedData['list'][0]['clouds']['all'];
202202
description = decodedData['list'][0]['weather'][0]['description'];
203+
cloudCover = decodedData['list'][0]['clouds']['all'];
203204
neerslag = decodedData['list'][0]['rain'];
205+
temperatureValue = decodedData['list'][0]['main']['temp'];
204206

205207
if (neerslag == null) {
206208
neerslag = 0;
207209
}
208210

209-
temperature = temperature.round();
211+
temperature = temperatureValue.round();
210212
print(location);
211213
print(temperature);
212214
print(cloudCover);

0 commit comments

Comments
 (0)