75 lines
1.9 KiB
Dart
75 lines
1.9 KiB
Dart
import 'package:didvan/models/category.dart';
|
|
|
|
import 'content.dart';
|
|
import 'tag.dart';
|
|
|
|
class RadarDetailsData {
|
|
final int id;
|
|
final String title;
|
|
final String image;
|
|
final int timeToRead;
|
|
final String createdAt;
|
|
final String? podcast;
|
|
final bool forManagers;
|
|
final bool marked;
|
|
final int comments;
|
|
final List<Tag> tags;
|
|
final List<Content> contents;
|
|
final List<Category> categories;
|
|
|
|
const RadarDetailsData({
|
|
required this.id,
|
|
required this.title,
|
|
required this.image,
|
|
required this.timeToRead,
|
|
required this.createdAt,
|
|
required this.podcast,
|
|
required this.forManagers,
|
|
required this.marked,
|
|
required this.comments,
|
|
required this.tags,
|
|
required this.contents,
|
|
required this.categories,
|
|
});
|
|
|
|
factory RadarDetailsData.fromJson(Map<String, dynamic> json) {
|
|
return RadarDetailsData(
|
|
id: json['id'],
|
|
title: json['title'],
|
|
image: json['image'],
|
|
timeToRead: json['timeToRead'],
|
|
createdAt: json['createdAt'],
|
|
podcast: json['podcast'],
|
|
forManagers: json['forManagers'],
|
|
marked: json['marked'],
|
|
comments: json['comments'],
|
|
tags: List<Tag>.from(json['tags'].map((tag) => Tag.fromJson(tag))),
|
|
contents: List<Content>.from(
|
|
json['contents'].map(
|
|
(content) => Content.fromJson(content),
|
|
),
|
|
),
|
|
categories: List<Category>.from(
|
|
json['categories'].map(
|
|
(cat) => Category.fromJson(cat),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'title': title,
|
|
'image': image,
|
|
'timeToRead': timeToRead,
|
|
'createdAt': createdAt,
|
|
'podcast': podcast,
|
|
'forManagers': forManagers,
|
|
'marked': marked,
|
|
'comments': comments,
|
|
'tags': tags.map((e) => e.toJson()).toList(),
|
|
'contents': contents.map((e) => e.toJson()).toList(),
|
|
'categories': categories.map((e) => e.toJson()).toList(),
|
|
};
|
|
}
|