refactor: dispatch on MusicServices constants instead of raw service ids

Service ids ('deezer', 'tidal', 'qobuz', 'spotify', 'amazon', 'local')
were compared as raw string literals in every dispatch chain. Introduce
MusicServices constants and use them at the comparison/switch sites so
a typo becomes a compile error instead of a silently dead branch.
This commit is contained in:
zarzet
2026-07-10 04:39:35 +07:00
parent c24a72c302
commit 19f69a6090
6 changed files with 53 additions and 34 deletions
+6 -4
View File
@@ -1,10 +1,12 @@
import 'package:spotiflac_android/constants/music_services.dart';
/// Maps a legacy prefixed resource id (e.g. "deezer:123") to its provider id,
/// or null when the value carries no known provider prefix.
String? legacyProviderIdFromResourceId(String value) {
if (value.startsWith('deezer:')) return 'deezer';
if (value.startsWith('qobuz:')) return 'qobuz';
if (value.startsWith('tidal:')) return 'tidal';
if (value.startsWith('spotify:')) return 'spotify';
if (value.startsWith('deezer:')) return MusicServices.deezer;
if (value.startsWith('qobuz:')) return MusicServices.qobuz;
if (value.startsWith('tidal:')) return MusicServices.tidal;
if (value.startsWith('spotify:')) return MusicServices.spotify;
return null;
}