lab7 джага джага

This commit is contained in:
antoc0der 2024-10-15 23:16:39 +04:00
parent c82d240d4c
commit d3dc6956f1
3 changed files with 10 additions and 1 deletions

View File

@ -22,8 +22,10 @@ class NewAttributesDataDto {
final String? description;
@JsonKey(name: 'urlToImage')
final String? imagelink;
@JsonKey(name: 'url')
final String? id;
const NewAttributesDataDto({this.title, this.description, this.imagelink});
const NewAttributesDataDto({this.id, this.title, this.description, this.imagelink});
factory NewAttributesDataDto.fromJson(Map<String, dynamic> json) =>
_$NewAttributesDataDtoFromJson(json);

View File

@ -18,6 +18,7 @@ NewsDto _$NewsDtoFromJson(Map<String, dynamic> json) => NewsDto(
NewAttributesDataDto _$NewAttributesDataDtoFromJson(
Map<String, dynamic> json) =>
NewAttributesDataDto(
id: json['url'] as String?,
title: json['title'] as String?,
description: json['description'] as String?,
imagelink: json['urlToImage'] as String?,

View File

@ -1,6 +1,7 @@
import 'package:pmu/data/dtos/news_dto.dart';
import 'package:pmu/domain/models/card.dart';
import 'package:pmu/domain/models/home.dart';
int _id = 0;
extension NewDataDtoToModel on NewAttributesDataDto {
CardData toDomain() => CardData(
@ -17,3 +18,8 @@ extension NewsDtoToModel on NewsDto {
nextPage: meta?.pagination?.next,
);
}
int _getId(){
_id+=1;
return _id;
}