23 lines
806 B
Dart
23 lines
806 B
Dart
import 'package:flutter_test_app/data/dtos/potions_dto.dart';
|
|
import 'package:flutter_test_app/domain/models/card.dart';
|
|
|
|
const String imagePlaceholder =
|
|
'https://cdn-icons-png.flaticon.com/512/4036/4036418.png';
|
|
|
|
extension PotionDataDtoToModel on PotionDataDto {
|
|
CardData toDomain() => CardData(
|
|
attributes?.name ?? 'UNKNOWN',
|
|
imageUrl: attributes?.image ?? imagePlaceholder,
|
|
descriptionText: _makeDescriptionText(attributes?.characteristics, attributes?.effect),
|
|
);
|
|
|
|
String _makeDescriptionText(String? characteristics, String? effect) {
|
|
return characteristics != null && effect != null
|
|
? '$characteristics - $effect'
|
|
: characteristics != null
|
|
? 'characteristics: $characteristics'
|
|
: effect != null
|
|
? 'effect: $effect'
|
|
: '';
|
|
}
|
|
} |