GanttTask constructor

GanttTask({
  1. required String id,
  2. required String name,
  3. required DateTime start,
  4. required DateTime end,
  5. required String status,
  6. required Color color,
  7. required String details,
  8. double? progress,
  9. String? dependsOn,
})

Implementation

GanttTask({
  required this.id,
  required this.name,
  required this.start,
  required this.end,
  required this.status,
  required this.color,
  required this.details,
  this.progress,
  this.dependsOn,
}) {
  // Ensure start is before end
  if (start.isAfter(end)) {
    final temp = start;
    start = end;
    end = temp;
  }
  // Ensure progress is within valid range
  if (progress != null) {
    if (progress! < 0.0) {
      progress = 0.0;
    } else if (progress! > 1.0) {
      progress = 1.0;
    }
  }
}