current_upload_asset.model.dart 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // ignore_for_file: public_member_api_docs, sort_constructors_first
  2. import 'dart:convert';
  3. class CurrentUploadAsset {
  4. final String id;
  5. final DateTime fileCreatedAt;
  6. final String fileName;
  7. final String fileType;
  8. final bool? iCloudAsset;
  9. CurrentUploadAsset({
  10. required this.id,
  11. required this.fileCreatedAt,
  12. required this.fileName,
  13. required this.fileType,
  14. this.iCloudAsset,
  15. });
  16. CurrentUploadAsset copyWith({
  17. String? id,
  18. DateTime? fileCreatedAt,
  19. String? fileName,
  20. String? fileType,
  21. bool? iCloudAsset,
  22. }) {
  23. return CurrentUploadAsset(
  24. id: id ?? this.id,
  25. fileCreatedAt: fileCreatedAt ?? this.fileCreatedAt,
  26. fileName: fileName ?? this.fileName,
  27. fileType: fileType ?? this.fileType,
  28. iCloudAsset: iCloudAsset ?? this.iCloudAsset,
  29. );
  30. }
  31. Map<String, dynamic> toMap() {
  32. return <String, dynamic>{
  33. 'id': id,
  34. 'fileCreatedAt': fileCreatedAt.millisecondsSinceEpoch,
  35. 'fileName': fileName,
  36. 'fileType': fileType,
  37. 'iCloudAsset': iCloudAsset,
  38. };
  39. }
  40. factory CurrentUploadAsset.fromMap(Map<String, dynamic> map) {
  41. return CurrentUploadAsset(
  42. id: map['id'] as String,
  43. fileCreatedAt:
  44. DateTime.fromMillisecondsSinceEpoch(map['fileCreatedAt'] as int),
  45. fileName: map['fileName'] as String,
  46. fileType: map['fileType'] as String,
  47. iCloudAsset:
  48. map['iCloudAsset'] != null ? map['iCloudAsset'] as bool : null,
  49. );
  50. }
  51. String toJson() => json.encode(toMap());
  52. factory CurrentUploadAsset.fromJson(String source) =>
  53. CurrentUploadAsset.fromMap(json.decode(source) as Map<String, dynamic>);
  54. @override
  55. String toString() {
  56. return 'CurrentUploadAsset(id: $id, fileCreatedAt: $fileCreatedAt, fileName: $fileName, fileType: $fileType, iCloudAsset: $iCloudAsset)';
  57. }
  58. @override
  59. bool operator ==(covariant CurrentUploadAsset other) {
  60. if (identical(this, other)) return true;
  61. return other.id == id &&
  62. other.fileCreatedAt == fileCreatedAt &&
  63. other.fileName == fileName &&
  64. other.fileType == fileType &&
  65. other.iCloudAsset == iCloudAsset;
  66. }
  67. @override
  68. int get hashCode {
  69. return id.hashCode ^
  70. fileCreatedAt.hashCode ^
  71. fileName.hashCode ^
  72. fileType.hashCode ^
  73. iCloudAsset.hashCode;
  74. }
  75. }