щас я буду все ломать

This commit is contained in:
Полина Чубыкина 2024-11-27 22:01:26 +04:00
parent 9c16de318d
commit a631adb572
4 changed files with 8 additions and 2 deletions

View File

@ -23,6 +23,7 @@ class PokemonDataDto {
final List<String>? evolvesTo;
final List<PokemonAbilityDto>? abilities;
final PokemonImagesDto? images;
final String? artist;
const PokemonDataDto({
this.id,
@ -31,6 +32,7 @@ class PokemonDataDto {
this.evolvesTo,
this.abilities,
this.images,
this.artist,
});
factory PokemonDataDto.fromJson(Map<String, dynamic> json) => _$PokemonDataDtoFromJson(json);

View File

@ -30,6 +30,7 @@ PokemonDataDto _$PokemonDataDtoFromJson(Map<String, dynamic> json) =>
images: json['images'] == null
? null
: PokemonImagesDto.fromJson(json['images'] as Map<String, dynamic>),
artist: json['artist'] as String?,
);
PokemonAbilityDto _$PokemonAbilityDtoFromJson(Map<String, dynamic> json) =>

View File

@ -17,7 +17,7 @@ extension PokemonDataDtoToModel on PokemonDataDto {
CardData toDomain() => CardData(
name ?? 'UNKNOWN',
imageUrl: images?.large ?? _imagePlaceholder,
descriptionText: _makeDescriptionText(types, evolvesTo, abilities),
descriptionText: _makeDescriptionText(types, evolvesTo, abilities, artist),
id: id,
);
@ -25,15 +25,18 @@ extension PokemonDataDtoToModel on PokemonDataDto {
List<String>? types,
List<String>? evolvesTo,
List<PokemonAbilityDto>? abilities,
String? artist,
) {
final typeText = types != null && types.isNotEmpty ? 'Types: ${types.join(", ")}' : '';
final evolvesToText = evolvesTo != null && evolvesTo.isNotEmpty ? 'Evolves To: ${evolvesTo.join(", ")}' : '';
final abilitiesText = abilities != null && abilities.isNotEmpty ? 'Abilities: ${abilities.map((a) => a.name).join(", ")}' : '';
final artistText = artist != null ? 'Artist: $artist' : '';
return [
typeText,
evolvesToText,
abilitiesText,
artistText,
].where((text) => text.isNotEmpty).join('\n');
}
}

View File

@ -30,7 +30,7 @@ class PokemonRepository extends ApiInterface {
};
if (q != null) {
queryParameters['q'] = 'name:$q*';
queryParameters['q'] = 'name:*$q*';
}
final Response<dynamic> response = await _dio.get<Map<dynamic, dynamic>>(