You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
// image_metadata_model.dart |
|
import 'package:problem_check_system/data/models/image_status.dart'; |
|
|
|
class ImageMetadata { |
|
final String localPath; |
|
final String? remoteUrl; |
|
final ImageStatus status; |
|
|
|
ImageMetadata({ |
|
required this.localPath, |
|
this.remoteUrl, |
|
required this.status, |
|
}); |
|
|
|
// For saving to SQL |
|
Map<String, dynamic> toMap() { |
|
return { |
|
'localPath': localPath, |
|
'remoteUrl': remoteUrl, |
|
'status': status.index, |
|
}; |
|
} |
|
|
|
// For reading from SQL |
|
factory ImageMetadata.fromMap(Map<String, dynamic> map) { |
|
return ImageMetadata( |
|
localPath: map['localPath'] as String, |
|
remoteUrl: map['remoteUrl'] as String?, |
|
status: ImageStatus.values[map['status'] as int], |
|
); |
|
} |
|
|
|
/// Creates a new [ImageMetadata] instance with optional new values. |
|
/// |
|
/// The original object remains unchanged. |
|
ImageMetadata copyWith({ |
|
String? localPath, |
|
String? remoteUrl, |
|
ImageStatus? status, |
|
}) { |
|
return ImageMetadata( |
|
localPath: localPath ?? this.localPath, |
|
remoteUrl: remoteUrl ?? this.remoteUrl, |
|
status: status ?? this.status, |
|
); |
|
} |
|
}
|
|
|