2024-09-25 15:53:40 +04:00
import ' package:json_annotation/json_annotation.dart ' ;
2024-10-07 19:36:49 +04:00
2024-09-25 15:53:40 +04:00
part ' news_dto.g.dart ' ;
2024-12-20 11:40:46 +04:00
//сборник классов, необходимых для десериализации с методами fromJson созданными автоматически в g файле. классы paginationdto, metadto - нахрен не упали насколько я понимаю
2024-09-25 15:53:40 +04:00
@ JsonSerializable ( createToJson: false )
2024-10-07 19:36:49 +04:00
class NewsDto {
2024-10-06 23:20:02 +04:00
@ JsonKey ( name: ' articles ' )
2024-09-25 19:28:26 +04:00
final List < NewAttributesDataDto > ? data ;
2024-09-25 15:53:40 +04:00
2024-10-07 19:36:49 +04:00
const NewsDto ( {
this . data ,
} ) ;
2024-12-20 11:40:46 +04:00
factory NewsDto . fromJson ( Map < String , dynamic > json ) = >
_ $NewsDtoFromJson ( json ) ;
2024-10-07 19:36:49 +04:00
}
2024-09-25 15:53:40 +04:00
@ JsonSerializable ( createToJson: false )
2024-10-07 19:36:49 +04:00
class NewAttributesDataDto {
2024-09-25 15:53:40 +04:00
final String ? title ;
2024-10-06 23:20:02 +04:00
final String ? description ;
@ JsonKey ( name: ' urlToImage ' )
2024-09-25 15:53:40 +04:00
final String ? imagelink ;
2024-10-15 23:16:39 +04:00
@ JsonKey ( name: ' url ' )
final String ? id ;
2024-12-20 11:40:46 +04:00
@ JsonKey ( name: ' publishedAt ' )
final String date ;
const NewAttributesDataDto ( {
this . id ,
this . title ,
this . description ,
this . imagelink ,
required this . date
} ) ;
2024-10-07 19:36:49 +04:00
factory NewAttributesDataDto . fromJson ( Map < String , dynamic > json ) = >
_ $NewAttributesDataDtoFromJson ( json ) ;
}
2024-12-20 22:07:38 +04:00