D1APP-48 radar overview model

This commit is contained in:
MohammadTaha Basiri 2022-01-05 19:03:31 +03:30
parent 6e13f37ede
commit fdff9669a6
2 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,16 @@
class Category {
final int id;
final String label;
const Category({required this.id, required this.label});
factory Category.fromJson(Map<String, dynamic> json) => Category(
id: json['id'],
label: json['label'],
);
Map<String, dynamic> toJson() => {
'id': id,
'label': label,
};
}

View File

@ -0,0 +1,53 @@
import 'category.dart';
class RadarOverview {
final int id;
final String image;
final String title;
final String description;
final int timeToRead;
final String createdAt;
final bool forManagers;
final bool marked;
final List<Category> categories;
const RadarOverview({
required this.id,
required this.image,
required this.title,
required this.description,
required this.timeToRead,
required this.createdAt,
required this.forManagers,
required this.marked,
required this.categories,
});
factory RadarOverview.fromJson(Map<String, dynamic> json) => RadarOverview(
id: json['id'],
image: json['image'],
title: json['title'],
description: json['description'],
timeToRead: json['timeToRead'],
createdAt: json['createdAt'],
forManagers: json['forManagers'],
marked: json['marked'],
categories: List<Category>.from(
json['categories'].map(
(category) => Category.fromJson(category),
),
),
);
Map<String, dynamic> toJson() => {
'id': id,
'image': image,
'title': title,
'description': description,
'timeToRead': timeToRead,
'createdAt': createdAt,
'forManagers': forManagers,
'marked': marked,
'categories': categories.map((e) => e.toJson()).toList(),
};
}