added comments and refactored code

This commit is contained in:
2025-01-28 22:36:23 +01:00
parent 6828a9a14b
commit 8f5ed07be9
12 changed files with 83 additions and 58 deletions

View File

@@ -30,12 +30,15 @@ class FloodStation {
riverName: parseStringValue(json['riverName']),
);
// sometimes the API returns a String instead of a double
static double parseDoubleValue(dynamic value) {
if (value is double) return value;
if (value is String) return double.parse(value);
return 0;
}
// sometimes the API returns a list of labels that are basically identical
/// if [value] is a List, the method return the first item
static String parseStringValue(dynamic value) {
if (value is String) return value;
if (value is List<dynamic>) return value[0];