53 lines
1.3 KiB
Dart
53 lines
1.3 KiB
Dart
import 'package:json_annotation/json_annotation.dart';
|
|
|
|
part 'news_dto.g.dart';
|
|
|
|
@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;
|
|
|
|
const NewAttributesDataDto({this.id, this.title, this.description, this.imagelink});
|
|
|
|
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);
|
|
}
|