щас я буду все ломать
This commit is contained in:
parent
9c16de318d
commit
a631adb572
@ -23,6 +23,7 @@ class PokemonDataDto {
|
|||||||
final List<String>? evolvesTo;
|
final List<String>? evolvesTo;
|
||||||
final List<PokemonAbilityDto>? abilities;
|
final List<PokemonAbilityDto>? abilities;
|
||||||
final PokemonImagesDto? images;
|
final PokemonImagesDto? images;
|
||||||
|
final String? artist;
|
||||||
|
|
||||||
const PokemonDataDto({
|
const PokemonDataDto({
|
||||||
this.id,
|
this.id,
|
||||||
@ -31,6 +32,7 @@ class PokemonDataDto {
|
|||||||
this.evolvesTo,
|
this.evolvesTo,
|
||||||
this.abilities,
|
this.abilities,
|
||||||
this.images,
|
this.images,
|
||||||
|
this.artist,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory PokemonDataDto.fromJson(Map<String, dynamic> json) => _$PokemonDataDtoFromJson(json);
|
factory PokemonDataDto.fromJson(Map<String, dynamic> json) => _$PokemonDataDtoFromJson(json);
|
||||||
|
@ -30,6 +30,7 @@ PokemonDataDto _$PokemonDataDtoFromJson(Map<String, dynamic> json) =>
|
|||||||
images: json['images'] == null
|
images: json['images'] == null
|
||||||
? null
|
? null
|
||||||
: PokemonImagesDto.fromJson(json['images'] as Map<String, dynamic>),
|
: PokemonImagesDto.fromJson(json['images'] as Map<String, dynamic>),
|
||||||
|
artist: json['artist'] as String?,
|
||||||
);
|
);
|
||||||
|
|
||||||
PokemonAbilityDto _$PokemonAbilityDtoFromJson(Map<String, dynamic> json) =>
|
PokemonAbilityDto _$PokemonAbilityDtoFromJson(Map<String, dynamic> json) =>
|
||||||
|
@ -17,7 +17,7 @@ extension PokemonDataDtoToModel on PokemonDataDto {
|
|||||||
CardData toDomain() => CardData(
|
CardData toDomain() => CardData(
|
||||||
name ?? 'UNKNOWN',
|
name ?? 'UNKNOWN',
|
||||||
imageUrl: images?.large ?? _imagePlaceholder,
|
imageUrl: images?.large ?? _imagePlaceholder,
|
||||||
descriptionText: _makeDescriptionText(types, evolvesTo, abilities),
|
descriptionText: _makeDescriptionText(types, evolvesTo, abilities, artist),
|
||||||
id: id,
|
id: id,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -25,15 +25,18 @@ extension PokemonDataDtoToModel on PokemonDataDto {
|
|||||||
List<String>? types,
|
List<String>? types,
|
||||||
List<String>? evolvesTo,
|
List<String>? evolvesTo,
|
||||||
List<PokemonAbilityDto>? abilities,
|
List<PokemonAbilityDto>? abilities,
|
||||||
|
String? artist,
|
||||||
) {
|
) {
|
||||||
final typeText = types != null && types.isNotEmpty ? 'Types: ${types.join(", ")}' : '';
|
final typeText = types != null && types.isNotEmpty ? 'Types: ${types.join(", ")}' : '';
|
||||||
final evolvesToText = evolvesTo != null && evolvesTo.isNotEmpty ? 'Evolves To: ${evolvesTo.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 abilitiesText = abilities != null && abilities.isNotEmpty ? 'Abilities: ${abilities.map((a) => a.name).join(", ")}' : '';
|
||||||
|
final artistText = artist != null ? 'Artist: $artist' : '';
|
||||||
|
|
||||||
return [
|
return [
|
||||||
typeText,
|
typeText,
|
||||||
evolvesToText,
|
evolvesToText,
|
||||||
abilitiesText,
|
abilitiesText,
|
||||||
|
artistText,
|
||||||
].where((text) => text.isNotEmpty).join('\n');
|
].where((text) => text.isNotEmpty).join('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -30,7 +30,7 @@ class PokemonRepository extends ApiInterface {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (q != null) {
|
if (q != null) {
|
||||||
queryParameters['q'] = 'name:$q*';
|
queryParameters['q'] = 'name:*$q*';
|
||||||
}
|
}
|
||||||
|
|
||||||
final Response<dynamic> response = await _dio.get<Map<dynamic, dynamic>>(
|
final Response<dynamic> response = await _dio.get<Map<dynamic, dynamic>>(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user