feat : Modèle avec sérialisation automatique
This commit is contained in:
35
lib/models/post.g.dart
Normal file
35
lib/models/post.g.dart
Normal file
@@ -0,0 +1,35 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'post.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Post _$PostFromJson(Map<String, dynamic> json) => Post(
|
||||
title: json['title'] as String,
|
||||
content: json['content'] as String,
|
||||
authorName: json['authorName'] as String,
|
||||
authorImageUrl: json['authorImageUrl'] as String,
|
||||
publishDate: DateTime.parse(json['publishDate'] as String),
|
||||
imageUrls: (json['imageUrls'] as List<dynamic>?)
|
||||
?.map((e) => e as String)
|
||||
.toList(),
|
||||
likesCount: (json['likesCount'] as num?)?.toInt() ?? 0,
|
||||
commentsCount: (json['commentsCount'] as num?)?.toInt() ?? 0,
|
||||
sharesCount: (json['sharesCount'] as num?)?.toInt() ?? 0,
|
||||
aspectRatio: (json['aspectRatio'] as num?)?.toDouble(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$PostToJson(Post instance) => <String, dynamic>{
|
||||
'title': instance.title,
|
||||
'content': instance.content,
|
||||
'authorName': instance.authorName,
|
||||
'authorImageUrl': instance.authorImageUrl,
|
||||
'publishDate': instance.publishDate.toIso8601String(),
|
||||
'imageUrls': instance.imageUrls,
|
||||
'likesCount': instance.likesCount,
|
||||
'commentsCount': instance.commentsCount,
|
||||
'sharesCount': instance.sharesCount,
|
||||
'aspectRatio': instance.aspectRatio,
|
||||
};
|
||||
Reference in New Issue
Block a user