abdicate object assigning responsibility
The ImagesService itself handles the conversion of Json to the object itself, instead of the ImagesApi
This commit is contained in:
parent
a0ed894016
commit
6a84a9bef0
9 changed files with 255 additions and 25 deletions
|
@ -1,3 +1,8 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'image_model.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class ImageModel {
|
||||
const ImageModel({
|
||||
required this.uri,
|
||||
|
@ -15,4 +20,9 @@ class ImageModel {
|
|||
|
||||
/// Given name of the image.
|
||||
final String imageName;
|
||||
|
||||
factory ImageModel.fromJson(Map<String, dynamic> json) => _$ImageModelFromJson(json);
|
||||
|
||||
/// Connect the generated [_$PersonToJson] function to the `toJson` method.
|
||||
Map<String, dynamic> toJson() => _$ImageModelToJson(this);
|
||||
}
|
||||
|
|
20
lib/features/home/data/models/image_model.g.dart
Normal file
20
lib/features/home/data/models/image_model.g.dart
Normal file
|
@ -0,0 +1,20 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'image_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
ImageModel _$ImageModelFromJson(Map<String, dynamic> json) => ImageModel(
|
||||
uri: Uri.parse(json['uri'] as String),
|
||||
imageIndex: json['imageIndex'] as int,
|
||||
imageName: json['imageName'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ImageModelToJson(ImageModel instance) =>
|
||||
<String, dynamic>{
|
||||
'uri': instance.uri.toString(),
|
||||
'imageIndex': instance.imageIndex,
|
||||
'imageName': instance.imageName,
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue