Favourites
This commit is contained in:
parent
6a84a9bef0
commit
1747ab0245
23 changed files with 469 additions and 67 deletions
|
@ -1,13 +1,11 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import '../dtos/image_model_dto.dart';
|
||||
|
||||
part 'image_model.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class ImageModel {
|
||||
const ImageModel({
|
||||
required this.uri,
|
||||
required this.imageIndex,
|
||||
required this.imageName,
|
||||
required this.isFavourite,
|
||||
});
|
||||
|
||||
/// An image's target [Uri].
|
||||
|
@ -21,8 +19,31 @@ class ImageModel {
|
|||
/// Given name of the image.
|
||||
final String imageName;
|
||||
|
||||
factory ImageModel.fromJson(Map<String, dynamic> json) => _$ImageModelFromJson(json);
|
||||
/// Whether the image was 'Starred' ot not.
|
||||
final bool isFavourite;
|
||||
|
||||
/// Connect the generated [_$PersonToJson] function to the `toJson` method.
|
||||
Map<String, dynamic> toJson() => _$ImageModelToJson(this);
|
||||
factory ImageModel.fromDto({
|
||||
required ImageModelDTO imageModelDto,
|
||||
required bool isFavourite,
|
||||
}) =>
|
||||
ImageModel(
|
||||
uri: imageModelDto.uri,
|
||||
imageIndex: imageModelDto.imageIndex,
|
||||
imageName: imageModelDto.imageName,
|
||||
isFavourite: isFavourite,
|
||||
);
|
||||
|
||||
ImageModel copyWith({
|
||||
Uri? uri,
|
||||
int? imageIndex,
|
||||
String? imageName,
|
||||
bool? isFavourite,
|
||||
}) {
|
||||
return ImageModel(
|
||||
uri: uri ?? this.uri,
|
||||
imageIndex: imageIndex ?? this.imageIndex,
|
||||
imageName: imageName ?? this.imageName,
|
||||
isFavourite: isFavourite ?? this.isFavourite,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue