import 'package:news_app/extension/base.dart'; class SpecialModel { SpecialModel({ List? records, int? total, int? size, int? current, int? pages, }) { _records = records; _total = total; _size = size; _current = current; _pages = pages; } SpecialModel.fromJson(dynamic json) { if (json['records'] != null) { _records = []; json['records'].forEach((v) { _records?.add(SpecialRecord.fromJson(v)); }); } _total = json['total'].toString().convertInt; _size = json['size'].toString().convertInt; _current = json['current'].toString().convertInt; _pages = json['pages'].toString().convertInt; } List? _records; int? _total; int? _size; int? _current; int? _pages; SpecialModel copyWith({ List? records, int? total, int? size, int? current, int? pages, }) => SpecialModel( records: records ?? _records, total: total ?? _total, size: size ?? _size, current: current ?? _current, pages: pages ?? _pages, ); List? get records => _records; int? get total => _total; int? get size => _size; int? get current => _current; int? get pages => _pages; Map toJson() { final map = {}; if (_records != null) { map['records'] = _records?.map((v) => v.toJson()).toList(); } map['total'] = _total; map['size'] = _size; map['current'] = _current; map['pages'] = _pages; return map; } } class SpecialRecord { SpecialRecord({ String? contentId, String? catalogId, String? contentType, String? title, String? logo, List? images, List? imagesSrc, String? author, // List? attributes, String? topFlag, String? publishDate, String? likeCount, String? commentCount, String? favoriteCount, String? viewCount, bool? isLiked, bool? isFavorite, }) { _contentId = contentId; _catalogId = catalogId; _contentType = contentType; _title = title; _logo = logo; _images = images; _imagesSrc = imagesSrc; _author = author; //_attributes = attributes; _topFlag = topFlag; _publishDate = publishDate; _likeCount = likeCount; _commentCount = commentCount; _favoriteCount = favoriteCount; _viewCount = viewCount; _isLiked = isLiked; _isFavorite = isFavorite; } SpecialRecord.fromJson(dynamic json) { _contentId = json['contentId']; _catalogId = json['catalogId']; _contentType = json['contentType']; _title = json['title']; _logo = json['logo']; _images = json['images'] != null ? json['images'].cast() : []; _imagesSrc = json['imagesSrc'] != null ? json['imagesSrc'].cast() : []; _author = json['author']; /* if (json['attributes'] != null) { _attributes = []; json['attributes'].forEach((v) { _attributes?.add(Dynamic.fromJson(v)); }); }*/ _topFlag = json['topFlag']; _publishDate = json['publishDate']; _likeCount = json['likeCount']; _commentCount = json['commentCount']; _favoriteCount = json['favoriteCount']; _viewCount = json['viewCount']; _isLiked = json['isLiked']; _isFavorite = json['isFavorite']; } String? _contentId; String? _catalogId; String? _contentType; String? _title; String? _logo; List? _images; List? _imagesSrc; String? _author; //List? _attributes; String? _topFlag; String? _publishDate; String? _likeCount; String? _commentCount; String? _favoriteCount; String? _viewCount; bool? _isLiked; bool? _isFavorite; SpecialRecord copyWith({ String? contentId, String? catalogId, String? contentType, String? title, String? logo, List? images, List? imagesSrc, String? author, // List? attributes, String? topFlag, String? publishDate, String? likeCount, String? commentCount, String? favoriteCount, String? viewCount, bool? isLiked, bool? isFavorite, }) => SpecialRecord( contentId: contentId ?? _contentId, catalogId: catalogId ?? _catalogId, contentType: contentType ?? _contentType, title: title ?? _title, logo: logo ?? _logo, images: images ?? _images, imagesSrc: imagesSrc ?? _imagesSrc, author: author ?? _author, //attributes: attributes ?? _attributes, topFlag: topFlag ?? _topFlag, publishDate: publishDate ?? _publishDate, likeCount: likeCount ?? _likeCount, commentCount: commentCount ?? _commentCount, favoriteCount: favoriteCount ?? _favoriteCount, viewCount: viewCount ?? _viewCount, isLiked: isLiked ?? _isLiked, isFavorite: isFavorite ?? _isFavorite, ); String? get contentId => _contentId; String? get catalogId => _catalogId; String? get contentType => _contentType; String? get title => _title; String? get logo => _logo; List? get images => _images; List? get imagesSrc => _imagesSrc; String? get author => _author; //List? get attributes => _attributes; String? get topFlag => _topFlag; String? get publishDate => _publishDate; String? get likeCount => _likeCount; String? get commentCount => _commentCount; String? get favoriteCount => _favoriteCount; String? get viewCount => _viewCount; bool? get isLiked => _isLiked; bool? get isFavorite => _isFavorite; Map toJson() { final map = {}; map['contentId'] = _contentId; map['catalogId'] = _catalogId; map['contentType'] = _contentType; map['title'] = _title; map['logo'] = _logo; map['images'] = _images; map['imagesSrc'] = _imagesSrc; map['author'] = _author; /* if (_attributes != null) { map['attributes'] = _attributes?.map((v) => v.toJson()).toList(); }*/ map['topFlag'] = _topFlag; map['publishDate'] = _publishDate; map['likeCount'] = _likeCount; map['commentCount'] = _commentCount; map['favoriteCount'] = _favoriteCount; map['viewCount'] = _viewCount; map['isLiked'] = _isLiked; map['isFavorite'] = _isFavorite; return map; } }