lab5 готова без поиска, надо менять апишку
This commit is contained in:
parent
02c53b7e40
commit
e7e2628e8b
@ -2,20 +2,12 @@ import 'package:json_annotation/json_annotation.dart';
|
||||
part 'news_dto.g.dart';
|
||||
@JsonSerializable(createToJson: false)
|
||||
class NewsDto{
|
||||
final List<NewDataDto>? data;
|
||||
@JsonKey(name: 'Главное')
|
||||
final List<NewAttributesDataDto>? data;
|
||||
const NewsDto({this.data});
|
||||
factory NewsDto.fromJson(Map<String, dynamic> json) => _$NewsDtoFromJson(json);
|
||||
}
|
||||
|
||||
@JsonSerializable(createToJson: false)
|
||||
class NewDataDto{
|
||||
final String? id;
|
||||
final String? type;
|
||||
final NewAttributesDataDto? attributes;
|
||||
const NewDataDto({this.id, this.type, this.attributes});
|
||||
|
||||
factory NewDataDto.fromJson(Map<String, dynamic> json) => _$NewDataDtoFromJson(json);
|
||||
}
|
||||
|
||||
@JsonSerializable(createToJson: false)
|
||||
class NewAttributesDataDto{
|
||||
@ -26,5 +18,4 @@ class NewAttributesDataDto{
|
||||
|
||||
const NewAttributesDataDto({this.title, this.summary, this.imagelink });
|
||||
factory NewAttributesDataDto.fromJson(Map<String, dynamic> json) => _$NewAttributesDataDtoFromJson(json);
|
||||
|
||||
}
|
@ -7,19 +7,11 @@ part of 'news_dto.dart';
|
||||
// **************************************************************************
|
||||
|
||||
NewsDto _$NewsDtoFromJson(Map<String, dynamic> json) => NewsDto(
|
||||
data: (json['data'] as List<dynamic>?)
|
||||
?.map((e) => NewDataDto.fromJson(e as Map<String, dynamic>))
|
||||
data: (json['Главное'] as List<dynamic>?)
|
||||
?.map((e) => NewAttributesDataDto.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
NewDataDto _$NewDataDtoFromJson(Map<String, dynamic> json) => NewDataDto(
|
||||
id: json['id'] as String?,
|
||||
type: json['type'] as String?,
|
||||
attributes: json['attributes'] == null
|
||||
? null
|
||||
: NewAttributesDataDto.fromJson(
|
||||
json['attributes'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
NewAttributesDataDto _$NewAttributesDataDtoFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
|
@ -1,10 +1,10 @@
|
||||
import 'package:pmu/data/dtos/news_dto.dart';
|
||||
import 'package:pmu/domain/models/card.dart';
|
||||
|
||||
extension NewDataDtoToModel on NewDataDto{
|
||||
extension NewDataDtoToModel on NewAttributesDataDto{
|
||||
CardData toDomain() => CardData(
|
||||
text: attributes?.title ?? 'UNKNOWN',
|
||||
imageUrl: attributes?.imagelink,
|
||||
descText: attributes?.summary ?? 'NOTHING',
|
||||
text: title ?? 'UNKNOWN',
|
||||
imageUrl: imagelink,
|
||||
descText: summary ?? 'NOTHING',
|
||||
);
|
||||
}
|
@ -29,12 +29,15 @@ class DetailsPage extends StatelessWidget {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
bottom: 16.0, top: 8.0, left: 8.0, right: 8.0),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
child: Image.network(
|
||||
data.imageUrl ?? '',
|
||||
fit: BoxFit.cover,
|
||||
))),
|
||||
)),
|
||||
)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
bottom: 4.0, top: 8.0, left: 8.0, right: 8.0),
|
||||
|
Loading…
Reference in New Issue
Block a user