комит перед тем как все поломаю
This commit is contained in:
parent
f49a119d5c
commit
20171525ce
@ -27,6 +27,7 @@ class PokemonDataDto {
|
||||
final int? height;
|
||||
final int? weight;
|
||||
final List<AbilityDto>? abilities;
|
||||
// final PokemonAttributesDataDto? attributes;
|
||||
|
||||
const PokemonDataDto({
|
||||
this.name,
|
||||
@ -35,11 +36,31 @@ class PokemonDataDto {
|
||||
this.height,
|
||||
this.weight,
|
||||
this.abilities,
|
||||
// this.attributes,
|
||||
});
|
||||
|
||||
factory PokemonDataDto.fromJson(Map<String, dynamic> json) => _$PokemonDataDtoFromJson(json);
|
||||
}
|
||||
|
||||
// @JsonSerializable(createToJson: false)
|
||||
// class PokemonAttributesDataDto {
|
||||
// final String? imageUrl;
|
||||
// final int? height;
|
||||
// final int? weight;
|
||||
// final List<AbilityDto>? abilities;
|
||||
// final PokemonSpritesDto? sprites;
|
||||
//
|
||||
// const PokemonAttributesDataDto({
|
||||
// this.imageUrl,
|
||||
// this.height,
|
||||
// this.weight,
|
||||
// this.abilities,
|
||||
// this.sprites,
|
||||
// });
|
||||
//
|
||||
// factory PokemonAttributesDataDto.fromJson(Map<String, dynamic> json) => _$PokemonAttributesDataDtoFromJson(json);
|
||||
// }
|
||||
|
||||
@JsonSerializable(createToJson: false)
|
||||
class AbilityDto {
|
||||
final AbilityDetailDto? ability;
|
||||
@ -57,3 +78,14 @@ class AbilityDetailDto {
|
||||
|
||||
factory AbilityDetailDto.fromJson(Map<String, dynamic> json) => _$AbilityDetailDtoFromJson(json);
|
||||
}
|
||||
|
||||
// @JsonSerializable(createToJson: false)
|
||||
// class PokemonSpritesDto {
|
||||
// final String front_default;
|
||||
//
|
||||
// const PokemonSpritesDto({
|
||||
// required this.front_default,
|
||||
// });
|
||||
//
|
||||
// factory PokemonSpritesDto.fromJson(Map<String, dynamic> json) => _$PokemonSpritesDtoFromJson(json);
|
||||
// }
|
||||
|
@ -17,6 +17,8 @@ extension PokemonDataDtoToModel on PokemonDataDto {
|
||||
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',
|
||||
);
|
||||
}
|
@ -29,19 +29,21 @@ class PokeRepository extends ApiInterface {
|
||||
'limit': pageSize,
|
||||
};
|
||||
|
||||
if (q != null && q.isNotEmpty) {
|
||||
url = '$_baseUrl/pokemon/$q';
|
||||
queryParameters = {
|
||||
'offset': page,
|
||||
'limit': pageSize,
|
||||
};
|
||||
}
|
||||
// if (q != null && q.isNotEmpty) {
|
||||
// url = '$_baseUrl/pokemon/$q';
|
||||
// queryParameters = {
|
||||
// 'offset': page,
|
||||
// 'limit': pageSize,
|
||||
// };
|
||||
// }
|
||||
|
||||
final Response<dynamic> response = await _dio.get<Map<dynamic, dynamic>>(
|
||||
url,
|
||||
queryParameters: queryParameters,
|
||||
);
|
||||
|
||||
// final PokemonDto dto = PokemonDto.fromJson(response.data as Map<String, dynamic>);
|
||||
// final HomeData data = dto.toDomain();
|
||||
final PokemonDto dto = PokemonDto.fromJson(response.data as Map<String, dynamic>);
|
||||
final List<PokemonDataDto> pokemonDataList = dto.results ?? [];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user