tsacdop-podcast-app-android/lib/state/playlist_state.dart

19 lines
568 B
Dart
Raw Normal View History

2020-11-03 18:54:03 +01:00
import 'package:state_notifier/state_notifier.dart';
import '../local_storage/key_value_storage.dart';
import '../type/playlist.dart';
class PlaylistProvider extends StateNotifier<List<Playlist>> {
PlaylistProvider() : super([]);
Future<void> loadPlaylist() async {
var storage = KeyValueStorage(playlistsAllKey);
var playlistEntities = await storage.getPlaylists();
var initState = [...playlistEntities.map(Playlist.fromEntity).toList()];
for (var playlist in initState) {
await playlist.getPlaylist();
}
state = initState;
}
}