didvan-app/lib/models/new_statistic/new_statistics_model.dart

104 lines
2.1 KiB
Dart

class NewStatisticModel {
final List<CategoryList> lists;
NewStatisticModel({required this.lists});
factory NewStatisticModel.fromJson(Map<String, dynamic> json) {
return NewStatisticModel(
lists: List<CategoryList>.from(
json['lists'].map((x) => CategoryList.fromJson(x))),
);
}
Map<String, dynamic> toJson() {
return {
'lists': List<dynamic>.from(lists.map((x) => x.toJson())),
};
}
}
class CategoryList {
final int category;
final String header;
final List<Content> contents;
CategoryList(
{required this.category, required this.header, required this.contents});
factory CategoryList.fromJson(Map<String, dynamic> json) {
return CategoryList(
category: json['category'],
header: json['header'],
contents:
List<Content>.from(json['contents'].map((x) => Content.fromJson(x))),
);
}
Map<String, dynamic> toJson() {
return {
'category': category,
'header': header,
'contents': List<dynamic>.from(contents.map((x) => x.toJson())),
};
}
}
class Content {
final int id;
final String label;
final String title;
final bool marked;
final Data data;
Content(
{required this.id,
required this.label,
required this.title,
required this.marked,
required this.data});
factory Content.fromJson(Map<String, dynamic> json) {
return Content(
id: json['id'],
label: json['label'],
title: json['title'],
marked: json['marked'],
data: Data.fromJson(json['data']),
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'label': label,
'title': title,
'marked': marked,
'data': data.toJson(),
};
}
}
class Data {
final String p;
final num dp;
final String dt;
Data({required this.p, required this.dp, required this.dt});
factory Data.fromJson(Map<String, dynamic> json) {
return Data(
p: json['p'],
dp: json['dp'],
dt: json['dt'],
);
}
Map<String, dynamic> toJson() {
return {
'p': p,
'dp': dp,
'dt': dt,
};
}
}