PMU-PIbd-32-Fedorenko-G-Y/flutter_app/lib/data/mappers/characters_mapper.dart
2024-10-17 15:20:02 +04:00

23 lines
710 B
Dart

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(
fullName,
imageUrl: imageUrl,
descriptionText: _makeDescriptionText(title, family),
);
String _makeDescriptionText(String? title, String? family) {
return title != null && family != null
? '$title of $family'
: title != null
? 'Title: $title'
: family != null
? 'Family: $family'
: '';
}
}