load static method
Implementation
static Future<Uint8List?> load(UArtworkRef ref) async {
if (ref.isEmpty) return null;
final Uint8List? cached = peek(ref);
if (cached != null) return cached;
if (!ref.isEmbedded) return null;
RandomAccessFile? handle;
try {
handle = await File(ref.filePath!).open();
final int length = await handle.length();
if (ref.offset < 0 || ref.offset >= length) return null;
final int available = length - ref.offset;
final int requested = ref.length > available ? available : ref.length;
if (requested <= 0 || requested > _maxSingleArtwork) return null;
await handle.setPosition(ref.offset);
final Uint8List bytes = await handle.read(requested);
_store(ref.cacheKey, bytes);
return bytes;
} on FileSystemException {
return null;
} finally {
await handle?.close();
}
}