import 'package:mobilki_lab1/data/dtos/pokemon_dto.dart'; import 'package:mobilki_lab1/domain/models/card.dart'; import 'package:mobilki_lab1/domain/models/home.dart'; const _imagePlaceholder = 'https://upload.wikimedia.org/wikipedia/en/archive/b/b1/20210811082420%21Portrait_placeholder.png'; extension PokemonDtoToModel on PokemonDto { HomeData toDomain() => HomeData( data: results?.map((e) => e.toDomain()).toList(), nextPage: next != null ? int.tryParse(next!.split('=')[1].split('&')[0]) : null, ); } extension PokemonDataDtoToModel on PokemonDataDto { CardData toDomain() => CardData( name ?? 'UNKNOWN', imageUrl: imageUrl ?? _imagePlaceholder, descriptionText: 'Height: ${height ?? 'UNKNOWN'} cm, Weight: ${weight ?? 'UNKNOWN'} g, Abilities: ${abilities?.map((ability) => ability.ability?.name ?? 'UNKNOWN').join(', ') ?? 'UNKNOWN'}', // imageUrl: attributes?.sprites?.front_default ?? _imagePlaceholder, // descriptionText: 'Height: ${attributes?.height ?? 'UNKNOWN'} cm, Weight: ${attributes?.weight ?? 'UNKNOWN'} g, Abilities: ${attributes?.abilities?.map((ability) => ability.ability?.name ?? 'UNKNOWN').join(', ') ?? 'UNKNOWN'}', id: url?.split('/')[6] ?? 'UNKNOWN', ); }