2024-10-14 21:25:43 +04:00
|
|
|
import 'package:mobilki_lab1/data/dtos/pokemon_dto.dart';
|
|
|
|
import 'package:mobilki_lab1/domain/models/card.dart';
|
|
|
|
|
|
|
|
const _imagePlaceholder =
|
|
|
|
'https://upload.wikimedia.org/wikipedia/en/archive/b/b1/20210811082420%21Portrait_placeholder.png';
|
|
|
|
|
|
|
|
extension PokemonDtoToModel on PokemonDto {
|
|
|
|
CardData toDomain() => CardData(
|
2024-10-16 23:18:15 +04:00
|
|
|
name,
|
|
|
|
imageUrl: sprites.front_default ?? _imagePlaceholder,
|
|
|
|
descriptionText: _makeDescriptionText(types),
|
|
|
|
);
|
2024-10-14 21:25:43 +04:00
|
|
|
|
|
|
|
String _makeDescriptionText(List<PokemonTypeDto> types) {
|
|
|
|
return 'Types: ${types.map((type) => type.type.name).join(', ')}';
|
|
|
|
}
|
2024-10-16 23:18:15 +04:00
|
|
|
}
|