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; final String? description;
@JsonKey(name: 'urlToImage') @JsonKey(name: 'urlToImage')
final String? imagelink; 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) => factory NewAttributesDataDto.fromJson(Map<String, dynamic> json) =>
_$NewAttributesDataDtoFromJson(json); _$NewAttributesDataDtoFromJson(json);

View File

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

View File

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