From 35f7ea719b2ba4ae275d873a5f1eb2df169fc877 Mon Sep 17 00:00:00 2001 From: MrBananaPants Date: Sun, 7 Mar 2021 14:04:43 +0100 Subject: [PATCH] Update initial weather values --- lib/main.dart | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 1cad133..351b499 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:ffi'; import 'package:geolocator/geolocator.dart'; import 'package:condition/condition.dart'; @@ -182,11 +183,12 @@ class BodyOfAppState extends State { getData(); } - var cloudCover; - var temperature; - String description; - String location; - var neerslag; + String location = 'nog geen data'; + String description = ''; + var cloudCover = 0; + var neerslag = 0; + double temperatureValue = 0; + var temperature = 0; void getData() async { 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 { var decodedData = jsonDecode(weatherData); location = decodedData['list'][0]['name']; - temperature = decodedData['list'][0]['main']['temp']; - cloudCover = decodedData['list'][0]['clouds']['all']; description = decodedData['list'][0]['weather'][0]['description']; + cloudCover = decodedData['list'][0]['clouds']['all']; neerslag = decodedData['list'][0]['rain']; + temperatureValue = decodedData['list'][0]['main']['temp']; if (neerslag == null) { neerslag = 0; } - temperature = temperature.round(); + temperature = temperatureValue.round(); print(location); print(temperature); print(cloudCover);