mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-26 14:01:03 +02:00
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.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
/// 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);
|
||||
}
|
||||
Reference in New Issue
Block a user