class Note { final int id; final String title; final String body; final List tags; final String noteType; final int? projectId; final int? milestoneId; final DateTime createdAt; final DateTime updatedAt; const Note({ required this.id, required this.title, required this.body, required this.tags, this.noteType = 'note', this.projectId, this.milestoneId, required this.createdAt, required this.updatedAt, }); factory Note.fromJson(Map json) => Note( id: json['id'] as int, title: json['title'] as String? ?? '', body: json['body'] as String? ?? '', tags: (json['tags'] as List?) ?.map((e) => e as String) .toList() ?? [], noteType: json['note_type'] as String? ?? 'note', projectId: json['project_id'] as int?, milestoneId: json['milestone_id'] as int?, createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), ); Map toJson() => { 'title': title, 'body': body, 'tags': tags, 'note_type': noteType, 'project_id': projectId, 'milestone_id': milestoneId, }; Note copyWith({ String? title, String? body, List? tags, String? noteType, Object? projectId = _undefined, Object? milestoneId = _undefined, }) => Note( id: id, title: title ?? this.title, body: body ?? this.body, tags: tags ?? this.tags, noteType: noteType ?? this.noteType, projectId: identical(projectId, _undefined) ? this.projectId : projectId as int?, milestoneId: identical(milestoneId, _undefined) ? this.milestoneId : milestoneId as int?, createdAt: createdAt, updatedAt: updatedAt, ); static const _undefined = Object(); }