fix(flutter): analyze errors after Plan B push

Cleared 5 errors + 1 warning + 1 info from CI flutter analyze on 5114a81:

- prefetcher.dart: Riverpod listener callbacks used (_, _) for two
  placeholder params — Dart 3 enforces unique names. Changed to (_, __).
- prefetcher.dart: Riverpod 3's AsyncValue exposes `.value` (nullable)
  not `.valueOrNull`. Three call sites updated.
- sync_controller.dart: doc comment had `?since=<cursor>` → analyzer
  warned about unintended HTML. Wrapped in backticks with `{cursor}`.
- sync_controller.dart: delete loop over heterogeneous Table list
  inferred as List<Table>; drift's delete() expects TableInfo. Unrolled
  to explicit per-table deletes.
- audio_cache_manager_test.dart: db.into(...).insertAll([...]) doesn't
  exist on InsertStatement — only insert/insertOnConflictUpdate. Used
  db.batch((b) => b.insertAll(table, [...])) instead, in two test cases.
- audio_handler.dart: LockCachingAudioSource is marked experimental in
  just_audio. Added // ignore: experimental_member_use — operator
  acknowledged the experimental status during brainstorming and we're
  the project; CI's --fatal-infos would otherwise gate.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-10 10:18:38 -04:00
parent 5114a8118c
commit 0d171490c3
4 changed files with 41 additions and 34 deletions
+5 -5
View File
@@ -18,18 +18,18 @@ class Prefetcher {
// The mediaItem stream changes whenever the active track changes // The mediaItem stream changes whenever the active track changes
// (skipNext/skipPrev or natural progression). Settings changes (e.g. // (skipNext/skipPrev or natural progression). Settings changes (e.g.
// operator bumps prefetch window) also trigger a reconcile. // operator bumps prefetch window) also trigger a reconcile.
_ref.listen<AsyncValue<MediaItem?>>(mediaItemProvider, (_, _) => _reconcile()); _ref.listen<AsyncValue<MediaItem?>>(mediaItemProvider, (_, __) => _reconcile());
_ref.listen<AsyncValue<CacheSettings>>(cacheSettingsProvider, (_, _) => _reconcile()); _ref.listen<AsyncValue<CacheSettings>>(cacheSettingsProvider, (_, __) => _reconcile());
} }
final Ref _ref; final Ref _ref;
Future<void> _reconcile() async { Future<void> _reconcile() async {
final settings = _ref.read(cacheSettingsProvider).valueOrNull; final settings = _ref.read(cacheSettingsProvider).value;
if (settings == null) return; if (settings == null) return;
final queue = _ref.read(queueProvider).valueOrNull ?? const <MediaItem>[]; final queue = _ref.read(queueProvider).value ?? const <MediaItem>[];
final current = _ref.read(mediaItemProvider).valueOrNull; final current = _ref.read(mediaItemProvider).value;
if (queue.isEmpty || current == null) return; if (queue.isEmpty || current == null) return;
final currentIdx = queue.indexWhere((m) => m.id == current.id); final currentIdx = queue.indexWhere((m) => m.id == current.id);
+7 -11
View File
@@ -19,7 +19,7 @@ class SyncResult {
} }
/// Drives the delta-sync against the server (#357 Plan A endpoint). /// Drives the delta-sync against the server (#357 Plan A endpoint).
/// Reads cursor from drift, calls /api/library/sync?since=<cursor>, /// Reads cursor from drift, calls `/api/library/sync?since={cursor}`,
/// applies upserts + deletes, advances cursor. /// applies upserts + deletes, advances cursor.
class SyncController extends AsyncNotifier<SyncResult?> { class SyncController extends AsyncNotifier<SyncResult?> {
@override @override
@@ -55,16 +55,12 @@ class SyncController extends AsyncNotifier<SyncResult?> {
// local state and retry once with cursor=0. // local state and retry once with cursor=0.
if (resp.statusCode == 410) { if (resp.statusCode == 410) {
await db.transaction(() async { await db.transaction(() async {
for (final t in [ await db.delete(db.cachedArtists).go();
db.cachedArtists, await db.delete(db.cachedAlbums).go();
db.cachedAlbums, await db.delete(db.cachedTracks).go();
db.cachedTracks, await db.delete(db.cachedLikes).go();
db.cachedLikes, await db.delete(db.cachedPlaylists).go();
db.cachedPlaylists, await db.delete(db.cachedPlaylistTracks).go();
db.cachedPlaylistTracks,
]) {
await db.delete(t).go();
}
await db.into(db.syncMetadata).insertOnConflictUpdate( await db.into(db.syncMetadata).insertOnConflictUpdate(
SyncMetadataCompanion.insert(cursor: const drift.Value(0)), SyncMetadataCompanion.insert(cursor: const drift.Value(0)),
); );
@@ -114,6 +114,7 @@ class MinstrelAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandl
final cacheFile = File('${cacheDir.path}/audio_cache/${t.id}.mp3'); final cacheFile = File('${cacheDir.path}/audio_cache/${t.id}.mp3');
debugPrint('audio_handler: cache miss for track.id=${t.id}, ' debugPrint('audio_handler: cache miss for track.id=${t.id}, '
'using LockCachingAudioSource → ${cacheFile.path}'); 'using LockCachingAudioSource → ${cacheFile.path}');
// ignore: experimental_member_use
return LockCachingAudioSource(parsed, return LockCachingAudioSource(parsed,
headers: headers, cacheFile: cacheFile); headers: headers, cacheFile: cacheFile);
} }
+14 -4
View File
@@ -31,12 +31,20 @@ void main() {
dioFactory: () async => Dio(), dioFactory: () async => Dio(),
cacheDirFactory: () async => tmp, cacheDirFactory: () async => tmp,
); );
await db.into(db.audioCacheIndex).insertAll([ await db.batch((b) {
b.insertAll(db.audioCacheIndex, [
AudioCacheIndexCompanion.insert( AudioCacheIndexCompanion.insert(
trackId: 'a', path: 'p', sizeBytes: 100, source: CacheSource.manual), trackId: 'a',
path: 'p',
sizeBytes: 100,
source: CacheSource.manual),
AudioCacheIndexCompanion.insert( AudioCacheIndexCompanion.insert(
trackId: 'b', path: 'p', sizeBytes: 250, source: CacheSource.incidental), trackId: 'b',
path: 'p',
sizeBytes: 250,
source: CacheSource.incidental),
]); ]);
});
expect(await mgr.usageBytes(), 350); expect(await mgr.usageBytes(), 350);
}); });
@@ -55,7 +63,8 @@ void main() {
final f2 = File('${tmp.path}/audio_cache/man.mp3'); final f2 = File('${tmp.path}/audio_cache/man.mp3');
await f2.create(recursive: true); await f2.create(recursive: true);
await f2.writeAsBytes(List.filled(100, 0)); await f2.writeAsBytes(List.filled(100, 0));
await db.into(db.audioCacheIndex).insertAll([ await db.batch((b) {
b.insertAll(db.audioCacheIndex, [
AudioCacheIndexCompanion.insert( AudioCacheIndexCompanion.insert(
trackId: 'inc', trackId: 'inc',
path: f1.path, path: f1.path,
@@ -67,6 +76,7 @@ void main() {
sizeBytes: 100, sizeBytes: 100,
source: CacheSource.manual), source: CacheSource.manual),
]); ]);
});
expect(await mgr.usageBytes(), 200); expect(await mgr.usageBytes(), 200);
await mgr.evict(targetBytes: 100); await mgr.evict(targetBytes: 100);
expect(await mgr.isCached('inc'), false); expect(await mgr.isCached('inc'), false);