load method
Implementation
Future<void> load() async {
if (_loaded || kIsWeb) return;
_loaded = true;
try {
final File file = await _indexFile();
final List<String> lines = await file.readAsLines();
_tracks
..clear()
..addAll(
lines
.where((String line) => line.trim().isNotEmpty)
.map((String line) => UTrackRecord.fromJson(jsonDecode(line) as Map<String, Object?>)),
);
} on FileSystemException {
_tracks.clear();
} on FormatException {
_tracks.clear();
}
_favorites
..clear()
..addAll((ULocalStorage.getString(_favoritesKey) ?? "").split("\n").where((String p) => p.isNotEmpty));
final String rawCounts = ULocalStorage.getString(_playCountKey) ?? "";
_playCounts.clear();
for (final String entry in rawCounts.split("\n")) {
final int separator = entry.lastIndexOf("|");
if (separator <= 0) continue;
_playCounts[entry.substring(0, separator)] = int.tryParse(entry.substring(separator + 1)) ?? 0;
}
notifyListeners();
}