import 'dart:convert'; T? asT(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 json) => NovelCategoryModel( tagId: asT(json['tagId'])!, title: asT(json['title'])!, cover: asT(json['cover'])!, ); int tagId; String title; String cover; @override String toString() { return jsonEncode(this); } Map toJson() => { 'tag_id': tagId, 'title': title, 'cover': cover, }; }