load method

Future<void> load()

Implementation

Future<void> load() async {
  if (_loaded || kIsWeb) return;
  _loaded = true;
  try {
    final String raw = await (await _file()).readAsString();
    final List<Object?> decoded = jsonDecode(raw) as List<Object?>;
    _playlists
      ..clear()
      ..addAll(decoded.whereType<Map<String, Object?>>().map(UPlaylist.fromJson));
  } on FileSystemException {
    _playlists.clear();
  } on FormatException {
    _playlists.clear();
  }
  notifyListeners();
}