added comments and refactored code
This commit is contained in:
@@ -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