RhythmBox/lib/services/audio_services/image.dart

22 lines
460 B
Dart
Raw Permalink Normal View History

2024-08-26 17:49:05 +00:00
import 'package:spotify/spotify.dart';
import 'package:collection/collection.dart';
enum ImagePlaceholder {
albumArt,
artist,
collection,
online,
}
extension SpotifyImageExtensions on List<Image>? {
2024-08-27 06:35:16 +00:00
String? asUrlString({
2024-08-26 17:49:05 +00:00
int index = 1,
}) {
final sortedImage = this?.sorted((a, b) => a.width!.compareTo(b.width!));
2024-08-27 06:35:16 +00:00
return sortedImage?[
index > sortedImage.length - 1 ? sortedImage.length - 1 : index]
.url;
2024-08-26 17:49:05 +00:00
}
}