Files
SpotiFLAC-Mobile/lib/utils/provider_resource_ids.dart
T
zarzet 2e7e2b1964 refactor(ui): share legacy provider-id resource helpers
legacyProviderIdFromResourceId and stripPrefixedResourceId were
copy-pasted in the album, artist, and playlist screens with slightly
different null semantics; the shared nullable variant plus explicit
?? 'spotify' fallbacks makes the difference visible at the call sites.
2026-07-10 10:12:20 +07:00

19 lines
704 B
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';
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);
}