58 lines
1.5 KiB
Dart
58 lines
1.5 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;
|
|
|
|
const 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,
|
|
});
|
|
|
|
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'],
|
|
categories: 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(),
|
|
};
|
|
}
|