Skip to content

Commit

Permalink
✨ add copyWith method for TimeEntry.
Browse files Browse the repository at this point in the history
  • Loading branch information
BirjuVachhani committed Nov 25, 2023
1 parent 87ff5b0 commit 99771d4
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions lib/model/time_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,43 @@ class TimeEntry with EquatableMixin {
billable = false,
isRunning = false;

/// CopyWith
TimeEntry copyWith({
int? id,
int? workspaceId,
int? projectId,
int? taskId,
String? description,
DateTime? start,
DateTime? stop,
Duration? duration,
int? userId,
int? uid,
int? wid,
int? pid,
bool? billable,
bool? isDeleted,
bool? isRunning,
}) {
return TimeEntry(
id: id ?? this.id,
workspaceId: workspaceId ?? this.workspaceId,
projectId: projectId ?? this.projectId,
taskId: taskId ?? this.taskId,
description: description ?? this.description,
start: start ?? this.start,
stop: stop ?? this.stop,
duration: duration ?? this.duration,
userId: userId ?? this.userId,
uid: uid ?? this.uid,
wid: wid ?? this.wid,
pid: pid ?? this.pid,
billable: billable ?? this.billable,
isDeleted: isDeleted ?? this.isDeleted,
isRunning: isRunning ?? this.isRunning,
);
}

factory TimeEntry.fromJson(Map<String, dynamic> json) {
json['isRunning'] =
json['stop'] == null || (json['stop'] is int && json['stop'] < 0);
Expand Down

0 comments on commit 99771d4

Please sign in to comment.