File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed
lib/features/user-library/data Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,9 @@ final class Favorite extends UserLibrary {
113
113
114
114
static const String boxKey = "favorite" ;
115
115
116
- const Favorite .empty () : super .empty (UserLibraryType .favorite);
116
+ factory Favorite .empty () {
117
+ return const Favorite (mediaItems: []);
118
+ }
117
119
}
118
120
119
121
@HiveType (typeId: 20 )
@@ -125,8 +127,6 @@ final class AlbumLibrary extends UserLibrary {
125
127
required super .mediaItems,
126
128
required super .images,
127
129
}) : super (type: UserLibraryType .album);
128
-
129
- const AlbumLibrary .empty () : super .empty (UserLibraryType .album);
130
130
}
131
131
132
132
@HiveType (typeId: 21 )
@@ -138,6 +138,4 @@ final class PlaylistLibrary extends UserLibrary {
138
138
required super .mediaItems,
139
139
required super .images,
140
140
}) : super (type: UserLibraryType .playlist);
141
-
142
- const PlaylistLibrary .empty () : super .empty (UserLibraryType .playlist);
143
141
}
Original file line number Diff line number Diff line change @@ -36,8 +36,8 @@ class UserLibraryRepository {
36
36
Future <void > favoriteSong (Song song) async {
37
37
final favourites = _box.get (
38
38
Favorite .boxKey,
39
- defaultValue: const Favorite .empty (),
40
- ) as UserLibrary ;
39
+ defaultValue: Favorite .empty (),
40
+ )! ;
41
41
final newFavourites = favourites.copyWith (
42
42
mediaItems: [...favourites.mediaItems, song],
43
43
);
@@ -47,8 +47,8 @@ class UserLibraryRepository {
47
47
Future <void > unfavoriteSong (Song song) async {
48
48
final favourites = _box.get (
49
49
Favorite .boxKey,
50
- defaultValue: const Favorite .empty (),
51
- ) as UserLibrary ;
50
+ defaultValue: Favorite .empty (),
51
+ )! ;
52
52
final newFavourites = favourites.copyWith (
53
53
mediaItems: favourites.mediaItems.where ((e) => e.id != song.id).toList (),
54
54
);
You can’t perform that action at this time.
0 commit comments