69 lines
1.5 KiB
Dart
69 lines
1.5 KiB
Dart
import 'package:didvan/models/tag.dart';
|
|
|
|
class InfographyContent {
|
|
final List<Content> contents;
|
|
final int lastPage;
|
|
|
|
InfographyContent({required this.contents, required this.lastPage});
|
|
|
|
factory InfographyContent.fromJson(Map<String, dynamic> json) {
|
|
return InfographyContent(
|
|
contents:
|
|
List<Content>.from(json['contents'].map((x) => Content.fromJson(x))),
|
|
lastPage: json['lastPage'],
|
|
);
|
|
}
|
|
}
|
|
|
|
class Content {
|
|
final int id;
|
|
final String title;
|
|
final String image;
|
|
final String category;
|
|
final String createdAt;
|
|
bool marked;
|
|
bool liked;
|
|
int likes;
|
|
|
|
final List<Tag> tags;
|
|
|
|
Content(
|
|
{required this.id,
|
|
required this.marked,
|
|
required this.liked,
|
|
required this.likes,
|
|
required this.createdAt,
|
|
required this.title,
|
|
required this.image,
|
|
required this.category,
|
|
required this.tags});
|
|
|
|
factory Content.fromJson(Map<String, dynamic> json) {
|
|
return Content(
|
|
id: json['id'],
|
|
marked: json['marked'],
|
|
liked: json['liked'],
|
|
likes: json['likes'],
|
|
createdAt: json['createdAt'],
|
|
title: json['title'],
|
|
image: json['image'],
|
|
category: json['category'],
|
|
tags: List<Tag>.from(json['tags'].map((x) => Tag.fromJson(x))),
|
|
);
|
|
}
|
|
}
|
|
|
|
// class Tag {
|
|
// final int id;
|
|
// final String label;
|
|
|
|
// Tag({required this.id, required this.label});
|
|
|
|
// factory Tag.fromJson(Map<String, dynamic> json) {
|
|
// return Tag(
|
|
// id: json['id'],
|
|
// label: json['label'],
|
|
// );
|
|
// }
|
|
// }
|