63 lines
1.7 KiB
Dart
63 lines
1.7 KiB
Dart
import 'package:didvan/models/category.dart';
|
|
|
|
class ItemOverview {
|
|
final int id;
|
|
final String title;
|
|
final String image;
|
|
final String description;
|
|
final int? timeToRead;
|
|
final String? reference;
|
|
final bool? forManagers;
|
|
final String createdAt;
|
|
final String? type;
|
|
final List<Category>? categories;
|
|
int? comments;
|
|
|
|
ItemOverview({
|
|
required this.id,
|
|
required this.title,
|
|
required this.image,
|
|
required this.description,
|
|
required this.timeToRead,
|
|
required this.reference,
|
|
required this.forManagers,
|
|
required this.createdAt,
|
|
required this.type,
|
|
required this.categories,
|
|
required this.comments,
|
|
});
|
|
|
|
factory ItemOverview.fromJson(Map<String, dynamic> json) => ItemOverview(
|
|
id: json['id'],
|
|
title: json['title'],
|
|
image: json['image'],
|
|
description: json['description'],
|
|
timeToRead: json['timeToRead'],
|
|
reference: json['reference'],
|
|
forManagers: json['forManagers'],
|
|
createdAt: json['createdAt'],
|
|
type: json['type'],
|
|
comments: json['comments'],
|
|
categories: json['categories'] == null
|
|
? null
|
|
: List<Category>.from(
|
|
json['categories'].map(
|
|
(cat) => Category.fromJson(cat),
|
|
),
|
|
),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'title': title,
|
|
'image': image,
|
|
'description': description,
|
|
'timeToRead': timeToRead,
|
|
'reference': reference,
|
|
'forManagers': forManagers,
|
|
'createdAt': createdAt,
|
|
'type': type,
|
|
'categories': categories?.map((e) => e.toJson()).toList(),
|
|
};
|
|
}
|