PMU_2024/lib/data/dtos/news_dto.dart
2024-12-20 11:40:46 +04:00

64 lines
1.7 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:json_annotation/json_annotation.dart';
part 'news_dto.g.dart';
//сборник классов, необходимых для десериализации с методами fromJson созданными автоматически в g файле. классы paginationdto, metadto - нахрен не упали насколько я понимаю
@JsonSerializable(createToJson: false)
class NewsDto {
@JsonKey(name: 'articles')
final List<NewAttributesDataDto>? data;
// final MetaDto? meta;
const NewsDto({
this.data,
// this.meta,
});
factory NewsDto.fromJson(Map<String, dynamic> json) =>
_$NewsDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class NewAttributesDataDto {
final String? title;
final String? description;
@JsonKey(name: 'urlToImage')
final String? imagelink;
@JsonKey(name: 'url')
final String? id;
@JsonKey(name: 'publishedAt')
final String date;
const NewAttributesDataDto({
this.id,
this.title,
this.description,
this.imagelink,
required this.date
});
factory NewAttributesDataDto.fromJson(Map<String, dynamic> json) =>
_$NewAttributesDataDtoFromJson(json);
}
//
// @JsonSerializable(createToJson: false)
// class MetaDto {
// final PaginationDto? pagination;
//
// const MetaDto({this.pagination});
//
// factory MetaDto.fromJson(Map<String, dynamic> json) =>
// _$MetaDtoFromJson(json);
// }
//
// @JsonSerializable(createToJson: false)
// class PaginationDto {
// final int? current;
// final int? next;
// final int? last;
//
// const PaginationDto({this.current, this.next, this.last});
//
// factory PaginationDto.fromJson(Map<String, dynamic> json) =>
// _$PaginationDtoFromJson(json);
// }