42 lines
1.0 KiB
Dart
42 lines
1.0 KiB
Dart
import 'dart:convert';
|
|
|
|
class ProjectTaskComment {
|
|
final int id;
|
|
final int taskId;
|
|
final int userId;
|
|
final String content;
|
|
final List<String> images;
|
|
final DateTime createdAt;
|
|
|
|
ProjectTaskComment({
|
|
required this.id,
|
|
required this.taskId,
|
|
required this.userId,
|
|
required this.content,
|
|
required this.images,
|
|
required this.createdAt,
|
|
});
|
|
|
|
factory ProjectTaskComment.fromJson(Map<String, dynamic> json) {
|
|
List<String> parsedImages = [];
|
|
if (json['images'] != null) {
|
|
if (json['images'] is String) {
|
|
try {
|
|
parsedImages = List<String>.from(jsonDecode(json['images']));
|
|
} catch (_) {}
|
|
} else if (json['images'] is List) {
|
|
parsedImages = List<String>.from(json['images']);
|
|
}
|
|
}
|
|
|
|
return ProjectTaskComment(
|
|
id: json['id'] as int,
|
|
taskId: json['taskId'] as int,
|
|
userId: json['userId'] as int,
|
|
content: json['content'] as String,
|
|
images: parsedImages,
|
|
createdAt: DateTime.parse(json['createdAt']),
|
|
);
|
|
}
|
|
}
|