23 lines
798 B
Dart
Raw Normal View History

2024-12-10 12:34:54 +04:00
import 'package:flutter_labs/data/dtos/potions_dto.dart';
import 'package:flutter_labs/domain/models/card.dart';
const String imagePlaceholder =
2024-12-11 12:04:34 +04:00
'https://cdn-icons-png.flaticon.com/512/4036/4036418.png';
2024-12-10 12:34:54 +04:00
extension PotionDataDtoToModel on PotionDataDto {
CardData toDomain() => CardData(
attributes?.name ?? 'UNKNOWN',
imageUrl: attributes?.image ?? imagePlaceholder,
2024-12-11 12:04:34 +04:00
descriptionText: _makeDescriptionText(attributes?.characteristics, attributes?.effect),
2024-12-10 12:34:54 +04:00
);
2024-12-11 12:04:34 +04:00
String _makeDescriptionText(String? characteristics, String? effect) {
return characteristics != null && effect != null
? '$characteristics - $effect'
: characteristics != null
? 'characteristics: $characteristics'
: effect != null
? 'effect: $effect'
: '';
}
2024-12-10 12:34:54 +04:00
}