import 'package:news_app/extension/base.dart'; class NewsDataModel { NewsDataModel({ List? records, int? total, int? size, int? current, int? pages, }) { _records = records; _total = total; _size = size; _current = current; _pages = pages; } NewsDataModel.fromJson(dynamic json) { if (json['records'] != null) { _records = []; json['records'].forEach((v) { _records?.add(NewsRecord.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; NewsDataModel copyWith({ List? records, int? total, int? size, int? current, int? pages, }) => NewsDataModel( 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 NewsRecord { NewsRecord({ String? contentId, String? catalogId, String? contentType, String? title, String? logo, List? images, List? imagesSrc, String? author, String? editor, String? summary, List? attributes, String? topFlag, List? keywords, List? tags, String? publishDateStr, 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; _editor = editor; _summary = summary; _attributes = attributes; _topFlag = topFlag; _keywords = keywords; _tags = tags; _publishDateStr = publishDateStr; _likeCount = likeCount; _commentCount = commentCount; _favoriteCount = favoriteCount; _viewCount = viewCount; _isLiked = isLiked; _isFavorite = isFavorite; } NewsRecord.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']; _editor = json['editor']; _summary = json['summary']; _attributes = json['attributes'] != null ? json['attributes'].cast() : []; _topFlag = json['topFlag']; _keywords = json['keywords'] != null ? json['keywords'].cast() : []; _tags = json['tags'] != null ? json['tags'].cast() : []; _publishDateStr = json['publishDateStr']; _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; String? _editor; String? _summary; List? _attributes; String? _topFlag; List? _keywords; List? _tags; String? _publishDateStr; String? _likeCount; String? _commentCount; String? _favoriteCount; String? _viewCount; bool? _isLiked; bool? _isFavorite; NewsRecord copyWith({ String? contentId, String? catalogId, String? contentType, String? title, String? logo, List? images, List? imagesSrc, String? author, String? editor, String? summary, List? attributes, String? topFlag, List? keywords, List? tags, String? publishDateStr, String? likeCount, String? commentCount, String? favoriteCount, String? viewCount, bool? isLiked, bool? isFavorite, }) => NewsRecord( contentId: contentId ?? _contentId, catalogId: catalogId ?? _catalogId, contentType: contentType ?? _contentType, title: title ?? _title, logo: logo ?? _logo, images: images ?? _images, imagesSrc: imagesSrc ?? _imagesSrc, author: author ?? _author, editor: editor ?? _editor, summary: summary ?? _summary, attributes: attributes ?? _attributes, topFlag: topFlag ?? _topFlag, keywords: keywords ?? _keywords, tags: tags ?? _tags, publishDateStr: publishDateStr ?? _publishDateStr, 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; String? get editor => _editor; String? get summary => _summary; List? get attributes => _attributes; String? get topFlag => _topFlag; List? get keywords => _keywords; List? get tags => _tags; String? get publishDateStr => _publishDateStr; 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; map['editor'] = _editor; map['summary'] = _summary; map['attributes'] = _attributes; map['topFlag'] = _topFlag; if (_keywords != null) { map['keywords'] = _keywords; } map['tags'] = _tags; map['publishDateStr'] = _publishDateStr; map['likeCount'] = _likeCount; map['commentCount'] = _commentCount; map['favoriteCount'] = _favoriteCount; map['viewCount'] = _viewCount; map['isLiked'] = _isLiked; map['isFavorite'] = _isFavorite; return map; } }