TermRemoteCtl/apps/mobile_app/lib/features/projects/project.dart

42 lines
1.2 KiB
Dart

import '../sessions/session.dart';
class Project {
Project({
required this.projectId,
required this.name,
required this.workingDirectory,
required this.createdAtUtc,
required this.updatedAtUtc,
});
final String projectId;
final String name;
final String workingDirectory;
final DateTime createdAtUtc;
final DateTime updatedAtUtc;
factory Project.fromJson(Map<String, dynamic> json) => Project(
projectId: json['projectId'] as String,
name: json['name'] as String,
workingDirectory: json['workingDirectory'] as String,
createdAtUtc: DateTime.parse(json['createdAtUtc'] as String),
updatedAtUtc: DateTime.parse(json['updatedAtUtc'] as String),
);
}
class ProjectDetail {
ProjectDetail({required this.project, required this.recentSessions});
final Project project;
final List<Session> recentSessions;
factory ProjectDetail.fromJson(Map<String, dynamic> json) => ProjectDetail(
project: Project.fromJson(json),
recentSessions: ((json['recentSessions'] as List?) ?? const <dynamic>[])
.map(
(entry) => Session.fromJson(Map<String, dynamic>.from(entry as Map)),
)
.toList(growable: false),
);
}