PMU-PIbd-32-Fedorenko-G-Y/flutter_app/lib/data/mappers/characters_mapper.dart

28 lines
824 B
Dart
Raw Normal View History

2024-10-17 15:20:02 +04:00
import 'package:flutter_app/data/dtos/thrones_character_dto.dart';
import 'package:flutter_app/domain/models/card.dart';
const _imagePlaceholder =
'https://upload.wikimedia.org/wikipedia/en/archive/b/b1/20210811082420%21Portrait_placeholder.png';
extension ThronesCharacterDtoToModel on ThronesCharacterDto {
CardData toDomain() => CardData(
descriptionText: _makeDescriptionText(title, family),
2024-11-04 16:34:24 +04:00
imageUrl: imageUrl,
firstName: firstName,
lastName: lastName,
title: title,
family: family,
fullName: fullName,
text: '',
2024-10-17 15:20:02 +04:00
);
String _makeDescriptionText(String? title, String? family) {
return title != null && family != null
? '$title of $family'
: title != null
? 'Title: $title'
: family != null
? 'Family: $family'
: '';
}
}