Enumeration.fromJSON constructor
Enumeration.fromJSON(
- dynamic id,
- dynamic json,
- dynamic stats,
- dynamic line,
- dynamic column,
- String user,
Implementation
Enumeration.fromJSON(
var id, var json, var stats, var line, var column, String user)
: super.fromJson(id, json, stats, line, column, user) {
comment = json['comment'] ?? "";
if (json["type"] == "Bool") {
values = ['OUI', 'NON'];
} else {
List<String> tmpValues = [];
//if the elements are a list do something else do something else
for (var i in stats[json['the_id']]['enumeration'] ?? []) {
if (i is List && i.length == 2) {
String secondElement = "";
if (i[1] is int) {
secondElement = "(${i[1]} disponibles)";
} else {
secondElement = "(${i[1]})";
}
tmpValues.add("${i[0]} $secondElement");
} else {
tmpValues.add(i.toString());
}
}
values = List<String>.from(tmpValues);
}
if (line[id] is List && line[id].isNotEmpty) {
value = line[id][0];
} else if (json.keys.contains("empty_is")) {
value = json["empty_is"];
} else {
if (json["type"] == "Bool") {
value = json["empty_is"];
} else {
value = null;
}
}
modifiable = json.keys.contains("modifiable") &&
json["modifiable"] == 2 &&
((line[id].length > 1 && line[id][1] == user) || line[id].length <= 1);
theId = json['the_id'] ?? "";
lineId = column['line_id'] ?? "";
ue = column['ue'] ?? "";
semester = column['semester'] ?? "";
year = (column['year'] ?? "").toString();
}