import 'package:equatable/equatable.dart'; /// Artist entity class Artist extends Equatable { final String id; final String name; final String? imageUrl; final String? bio; final List genres; final int popularity; final String? spotifyId; final String? youtubeId; final DateTime createdAt; final DateTime updatedAt; const Artist({ required this.id, required this.name, this.imageUrl, this.bio, this.genres = const [], this.popularity = 0, this.spotifyId, this.youtubeId, required this.createdAt, required this.updatedAt, }); /// Create Artist from JSON factory Artist.fromJson(Map json) { return Artist( id: json['id'] as String, name: json['name'] as String, imageUrl: json['image_url'] as String?, bio: json['bio'] as String?, genres: (json['genres'] as List?) ?.map((e) => e as String) .toList() ?? [], popularity: json['popularity'] as int? ?? 0, spotifyId: json['spotify_id'] as String?, youtubeId: json['youtube_id'] as String?, createdAt: json['created_at'] != null ? DateTime.parse(json['created_at'] as String) : DateTime.now(), updatedAt: json['updated_at'] != null ? DateTime.parse(json['updated_at'] as String) : DateTime.now(), ); } @override List get props => [id, name, genres, popularity]; }