38 lines
939 B
Dart
38 lines
939 B
Dart
class CategoryModel {
|
|
late int id;
|
|
late String name;
|
|
// late String imageUrl;
|
|
late String iconPath;
|
|
late List<CategoryModel> children;
|
|
int? parentId;
|
|
String? slug;
|
|
String? description;
|
|
|
|
CategoryModel({
|
|
required this.id,
|
|
required this.name,
|
|
// required this.imageUrl,
|
|
required this.iconPath,
|
|
required this.children,
|
|
this.parentId,
|
|
this.slug,
|
|
this.description,
|
|
});
|
|
|
|
CategoryModel.fromJson(Map<String, dynamic> json) {
|
|
id = json['id'];
|
|
name = json['name'] ?? '';
|
|
parentId = json['parent_id'];
|
|
slug = json['slug'] ?? '';
|
|
description = json['description'] ?? '';
|
|
// imageUrl = json['image_url'] ?? 'assets/phone.jpg'; //TODO: change
|
|
iconPath = json['category_icon_path'] ?? '';
|
|
if (json['children'] != null) {
|
|
children = <CategoryModel>[];
|
|
json['children'].forEach((v) {
|
|
children.add(new CategoryModel.fromJson(v));
|
|
});
|
|
}
|
|
}
|
|
}
|