added explicit attribute

pull/19/head
Emre KARTAL 2 years ago
parent ae9ad68030
commit 0a588ed822

@ -7,11 +7,12 @@ class Music {
String? _previewUrl; String? _previewUrl;
DateTime? _date; DateTime? _date;
double? _duration; double? _duration;
bool _explicit = false;
List<Artist> _artists; List<Artist> _artists;
// Constructor // Constructor
Music(this._id, this._title, this._cover, this._previewUrl, this._date, Music(this._id, this._title, this._cover, this._previewUrl, this._date,
this._duration, this._artists); this._duration, this._explicit, this._artists);
//Getters and setters //Getters and setters
String? get id => _id; String? get id => _id;
@ -46,6 +47,12 @@ class Music {
_duration = value; _duration = value;
} }
bool get explicit => _explicit;
set explicit(bool value) {
_explicit = value;
}
List<Artist> get artists => _artists; List<Artist> get artists => _artists;
set artists(List<Artist> value) { set artists(List<Artist> value) {

@ -34,6 +34,7 @@ class MusicViewModel {
responseData['preview_url'], responseData['preview_url'],
DateTime.parse(responseData['album']['release_date']), DateTime.parse(responseData['album']['release_date']),
responseData['duration_ms'] / 1000, responseData['duration_ms'] / 1000,
responseData['explicit'],
artists); artists);
} else { } else {
throw Exception( throw Exception(
@ -57,6 +58,7 @@ class MusicViewModel {
track['preview_url'], track['preview_url'],
DateTime.now(), DateTime.now(),
track['duration_ms'] / 1000, track['duration_ms'] / 1000,
track['explicit'],
artists)); artists));
} }
@ -188,6 +190,7 @@ class MusicViewModel {
track['preview_url'], track['preview_url'],
DateTime.now(), DateTime.now(),
track['duration_ms'] / 1000, track['duration_ms'] / 1000,
track['explicit'],
artists)); artists));
} }

@ -7,7 +7,7 @@ Future<void> main() async {
Music m = await musicVM.getMusic('295SxdR1DqunCNwd0U767w'); Music m = await musicVM.getMusic('295SxdR1DqunCNwd0U767w');
print("id : ${m.id.toString()}, cover : ${m.cover}, title : ${m.title}"); print("id : ${m.id.toString()}, cover : ${m.cover}, title : ${m.title}");
print("date : ${m.date.toString()}, preview : ${m.previewUrl}, duration : ${m.duration}"); print("date : ${m.date.toString()}, preview : ${m.previewUrl}, duration : ${m.duration}, explicit : ${m.explicit}");
for (Artist a in m.artists) { for (Artist a in m.artists) {
print("id : ${a.id}, name : ${a.name}"); print("id : ${a.id}, name : ${a.name}");
} }
@ -17,7 +17,7 @@ Future<void> main() async {
List<Music> musics = await musicVM.getMusicsWithName('Shavkat'); List<Music> musics = await musicVM.getMusicsWithName('Shavkat');
for (Music m in musics) { for (Music m in musics) {
print("id : ${m.id.toString()}, cover : ${m.cover}, title : ${m.title}"); print("id : ${m.id.toString()}, cover : ${m.cover}, title : ${m.title}");
print("date : ${m.date.toString()}, preview : ${m.previewUrl}, duration : ${m.duration}"); print("date : ${m.date.toString()}, preview : ${m.previewUrl}, duration : ${m.duration}, explicit : ${m.explicit}");
for (Artist a in m.artists) { for (Artist a in m.artists) {
print("id : ${a.id}, name : ${a.name}"); print("id : ${a.id}, name : ${a.name}");
} }
@ -28,7 +28,7 @@ Future<void> main() async {
List<Music> musics2 = await musicVM.getMusicsWithArtistName('jul'); List<Music> musics2 = await musicVM.getMusicsWithArtistName('jul');
for (Music m in musics2) { for (Music m in musics2) {
print("id : ${m.id.toString()}, cover : ${m.cover}, title : ${m.title}"); print("id : ${m.id.toString()}, cover : ${m.cover}, title : ${m.title}");
print("date : ${m.date.toString()}, preview : ${m.previewUrl}, duration : ${m.duration}"); print("date : ${m.date.toString()}, preview : ${m.previewUrl}, duration : ${m.duration}, explicit : ${m.explicit}");
for (Artist a in m.artists) { for (Artist a in m.artists) {
print("id : ${a.id}, name : ${a.name}"); print("id : ${a.id}, name : ${a.name}");
} }
@ -51,7 +51,7 @@ Future<void> main() async {
List<Music> topMusics = await musicVM.getTopMusicsWithArtistId('3NH8t45zOTqzlZgBvZRjvB'); List<Music> topMusics = await musicVM.getTopMusicsWithArtistId('3NH8t45zOTqzlZgBvZRjvB');
for (Music m in topMusics) { for (Music m in topMusics) {
print("id : ${m.id.toString()}, cover : ${m.cover}, title : ${m.title}"); print("id : ${m.id.toString()}, cover : ${m.cover}, title : ${m.title}");
print("date : ${m.date.toString()}, preview : ${m.previewUrl}, duration : ${m.duration}"); print("date : ${m.date.toString()}, preview : ${m.previewUrl}, duration : ${m.duration}, explicit : ${m.explicit}");
for (Artist a in m.artists) { for (Artist a in m.artists) {
print("id : ${a.id}, name : ${a.name}"); print("id : ${a.id}, name : ${a.name}");
} }

Loading…
Cancel
Save