fixed nullable mess with editor ids
This commit is contained in:
@@ -6,10 +6,10 @@ class Project {
|
||||
String name;
|
||||
String language;
|
||||
File path;
|
||||
String? e0;
|
||||
String? e1;
|
||||
String? e2;
|
||||
String? e3;
|
||||
String e0;
|
||||
String e1;
|
||||
String e2;
|
||||
String e3;
|
||||
bool isGit;
|
||||
|
||||
Project(
|
||||
@@ -17,10 +17,10 @@ class Project {
|
||||
this.language,
|
||||
this.path,
|
||||
this.isGit, {
|
||||
this.e0 = null,
|
||||
this.e1 = null,
|
||||
this.e2 = null,
|
||||
this.e3 = null,
|
||||
this.e0 = "",
|
||||
this.e1 = "",
|
||||
this.e2 = "",
|
||||
this.e3 = "",
|
||||
});
|
||||
|
||||
factory Project.newValidated(String name, String lang, String path) {
|
||||
@@ -43,27 +43,19 @@ class Project {
|
||||
"language": language,
|
||||
"path": path.path,
|
||||
"isGit": isGit,
|
||||
"e0": e0,
|
||||
"e1": e1,
|
||||
"e2": e2,
|
||||
"e3": e3,
|
||||
};
|
||||
if (e0 == null) {
|
||||
fin["e0"] = e0;
|
||||
}
|
||||
if (e1 == null) {
|
||||
fin["e1"] = e1;
|
||||
}
|
||||
if (e2 == null) {
|
||||
fin["e2"] = e2;
|
||||
}
|
||||
if (e3 == null) {
|
||||
fin["e3"] = e3;
|
||||
}
|
||||
return fin;
|
||||
}
|
||||
|
||||
factory Project.fromJson(Map<String, dynamic> data) {
|
||||
final String? e0 = data["e0"];
|
||||
final String? e1 = data["e1"];
|
||||
final String? e2 = data["e2"];
|
||||
final String? e3 = data["e3"];
|
||||
factory Project.fromJson(Map<String, dynamic> data, List<String> editorList) {
|
||||
final String e0 = editorList.contains(data["e0"]) ? data["e0"] : "";
|
||||
final String e1 = editorList.contains(data["e1"]) ? data["e1"] : "";
|
||||
final String e2 = editorList.contains(data["e2"]) ? data["e2"] : "";
|
||||
final String e3 = editorList.contains(data["e3"]) ? data["e3"] : "";
|
||||
return Project(
|
||||
data["name"] as String,
|
||||
data["language"] as String,
|
||||
@@ -76,7 +68,7 @@ class Project {
|
||||
);
|
||||
}
|
||||
|
||||
String? getEditor(enumb) {
|
||||
String getEditor(int enumb) {
|
||||
switch (enumb) {
|
||||
case 0:
|
||||
return e0;
|
||||
@@ -87,12 +79,11 @@ class Project {
|
||||
case 3:
|
||||
return e3;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
void setEditor(int enumb, String? edt) {
|
||||
void setEditor(int enumb, String edt) {
|
||||
switch (enumb) {
|
||||
case 0:
|
||||
e0 = edt;
|
||||
|
||||
Reference in New Issue
Block a user