v1.0.1
This commit is contained in:
38
lib/models/novel/category_model.dart
Normal file
38
lib/models/novel/category_model.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'dart:convert';
|
||||
|
||||
T? asT<T>(dynamic value) {
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class NovelCategoryModel {
|
||||
NovelCategoryModel({
|
||||
required this.tagId,
|
||||
required this.title,
|
||||
required this.cover,
|
||||
});
|
||||
|
||||
factory NovelCategoryModel.fromJson(Map<String, dynamic> json) =>
|
||||
NovelCategoryModel(
|
||||
tagId: asT<int>(json['tagId'])!,
|
||||
title: asT<String>(json['title'])!,
|
||||
cover: asT<String>(json['cover'])!,
|
||||
);
|
||||
|
||||
int tagId;
|
||||
String title;
|
||||
String cover;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'tag_id': tagId,
|
||||
'title': title,
|
||||
'cover': cover,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user