fix: year can be null

This commit is contained in:
Matyáš Caras 2024-06-21 12:20:01 +02:00
parent 4bc2ad1285
commit 017c52f96d
Signed by: hernik
GPG key ID: 2A3175F98820C5C6
2 changed files with 2 additions and 2 deletions

View file

@ -26,7 +26,7 @@ class Album {
@JsonKey(name: "artist")
final String artistName;
final String artistId;
final int year;
final int? year;
final int songCount;
final List<String> genres;
final int duration;

View file

@ -13,7 +13,7 @@ Album _$AlbumFromJson(Map<String, dynamic> json) => Album(
playCount: (json['playCount'] as num?)?.toInt() ?? 0,
artistName: json['artist'] as String,
artistId: json['artistId'] as String,
year: (json['year'] as num).toInt(),
year: (json['year'] as num?)?.toInt(),
songCount: (json['songCount'] as num).toInt(),
genres:
(json['genres'] as List<dynamic>).map((e) => e as String).toList(),