Artist.fromJson constructor

Artist.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory Artist.fromJson(Map<String, dynamic> json) {
  return Artist(
    id: json['id'],
    name: json['name'],
    genres: (json['genres'] as List<dynamic>?)
        ?.map((e) => e.toString())
        .toList(),
    popularity: json['popularity'] ?? 0,
    followers: json['followers'] != null ? json['followers']['total'] ?? 0 : 0,
    spotifyUrl: json['external_urls']['spotify'],
    href: json['href'],
    type: json['type'],
    uri: json['uri'],
    images: List<String>.from(
      (json['images'] ?? []).map((img) => img['url']),
    ),
  );
}