import 'package:pmu_labworks/data/dtos/characters_dto.dart'; import 'package:pmu_labworks/domain/models/comment.dart'; import 'package:pmu_labworks/domain/models/user.dart'; extension CharacterDataDtoToModel on CharacterDataDto { CommentModel toDomain() => CommentModel( title: type ?? 'UNKNOWN', text: _makeDescriptionText(attributes?.born, attributes?.died), user: UserModel( nickname: attributes?.name ?? 'Noname', avatarUrl: attributes?.image), ); String _makeDescriptionText(String? born, String? died) { if (born != null && died != null) { return '$born - $died'; } else if (born != null) { return 'born: $born'; } else if (died != null) { return 'died: $died'; } else { return ''; } } }