Files
Prod/lib/models/project.dart
Phani Pavan K d3a00dc394
All checks were successful
Build CI / AMD64 Build (push) Successful in 2m0s
Build CI / ARM64 Build (push) Successful in 7m45s
added launch buttons
2026-02-25 23:58:48 +05:30

83 lines
1.7 KiB
Dart

import 'package:prod/models/editor.dart';
import "dart:io";
import "package:path/path.dart" as p;
class Project {
final String name;
final String language;
final File path;
final Editor? e0;
final Editor? e1;
final Editor? e2;
final Editor? e3;
final bool isGit;
Project(
this.name,
this.language,
this.path,
this.isGit, {
this.e0 = null,
this.e1 = null,
this.e2 = null,
this.e3 = null,
});
factory Project.newValidated(String name, String lang, String path) {
final File fpath = File(path);
print(fpath.absolute.path);
if (fpath.existsSync()) {
print("Project not found!!!");
} else {
print("Project Exists on disk");
}
String gitPath = p.join(path, ".git", "HEAD");
final bool isGit = File(gitPath).existsSync();
return Project(name, lang, fpath, isGit);
}
Map<String, dynamic> toJson() {
Map<String, dynamic> fin = {
"name": name,
"language": language,
"path": path.path,
"isGit": isGit,
};
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 Editor? e0 = data["e0"];
final Editor? e1 = data["e1"];
final Editor? e2 = data["e2"];
final Editor? e3 = data["e3"];
return Project(
data["name"] as String,
data["language"] as String,
File(data["path"] as String),
data["isGit"] as bool,
e0: e0,
e1: e1,
e2: e2,
e3: e3,
);
}
// bool validatePath(){
// return File
// }
}