feat : Modèle avec sérialisation automatique
This commit is contained in:
33
lib/models/post.dart
Normal file
33
lib/models/post.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'post.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class Post {
|
||||
final String title;
|
||||
final String content;
|
||||
final String authorName;
|
||||
final String authorImageUrl;
|
||||
final DateTime publishDate;
|
||||
final List<String>? imageUrls;
|
||||
final int likesCount;
|
||||
final int commentsCount;
|
||||
final int sharesCount;
|
||||
final double? aspectRatio; // Nouveau paramètre pour le ratio (largeur/hauteur)
|
||||
|
||||
Post({
|
||||
required this.title,
|
||||
required this.content,
|
||||
required this.authorName,
|
||||
required this.authorImageUrl,
|
||||
required this.publishDate,
|
||||
this.imageUrls,
|
||||
this.likesCount = 0,
|
||||
this.commentsCount = 0,
|
||||
this.sharesCount = 0,
|
||||
this.aspectRatio,
|
||||
});
|
||||
|
||||
factory Post.fromJson(Map<String, dynamic> json) => _$PostFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$PostToJson(this);
|
||||
}
|
||||
Reference in New Issue
Block a user