immich/mobile/lib/domain/models/asset/asset.model.dart
2025-04-21 16:40:28 +05:30

65 lines
1.3 KiB
Dart

import 'package:immich_mobile/utils/nullable_value.dart';
part 'local_asset.model.dart';
part 'merged_asset.model.dart';
part 'remote_asset.model.dart';
enum AssetType {
// do not change this order!
other,
image,
video,
audio,
}
sealed class Asset {
final String name;
final String? checksum;
final AssetType type;
final DateTime createdAt;
final DateTime updatedAt;
final int? durationInSeconds;
const Asset({
required this.name,
required this.checksum,
required this.type,
required this.createdAt,
required this.updatedAt,
this.durationInSeconds,
});
@override
String toString() {
return '''Asset {
name: $name,
type: $type,
createdAt: $createdAt,
updatedAt: $updatedAt,
durationInSeconds: ${durationInSeconds ?? "<NA>"}
}''';
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
if (other is Asset) {
return name == other.name &&
type == other.type &&
createdAt == other.createdAt &&
updatedAt == other.updatedAt &&
durationInSeconds == other.durationInSeconds;
}
return false;
}
@override
int get hashCode {
return name.hashCode ^
type.hashCode ^
createdAt.hashCode ^
updatedAt.hashCode ^
durationInSeconds.hashCode;
}
}