added comments and refactored code
This commit is contained in:
1 parent
6828a9a14b
commit
8f5ed07be9
12 files changed
+83
-58
No files matched your search
@@ -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];
|
||||
|
||||
Reference in new issue
Block a user