Files
SpotiFLAC-Mobile/lib/utils/provider_resource_ids.dart
T
zarzet 19f69a6090 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.
2026-07-10 10:17:59 +07:00

21 lines
819 B
Dart

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 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;
}
/// Strips a leading "provider:" prefix from a resource id, if present.
String stripPrefixedResourceId(String value) {
final colonIndex = value.indexOf(':');
if (colonIndex <= 0 || colonIndex == value.length - 1) {
return value;
}
return value.substring(colonIndex + 1);
}