2025-08-20 15:36:44 -04:00
|
|
|
part of 'image_request.dart';
|
|
|
|
|
|
|
|
|
|
class ThumbhashImageRequest extends ImageRequest {
|
|
|
|
|
final String thumbhash;
|
|
|
|
|
|
|
|
|
|
ThumbhashImageRequest({required this.thumbhash});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<ImageInfo?> load(ImageDecoderCallback decode, {double scale = 1.0}) async {
|
|
|
|
|
if (_isCancelled) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-24 14:34:29 -05:00
|
|
|
final Map<String, int> info = await localImageApi.getThumbhash(thumbhash);
|
|
|
|
|
final frame = await _fromDecodedPlatformImage(info["pointer"]!, info["width"]!, info["height"]!, info["rowBytes"]!);
|
2025-08-20 15:36:44 -04:00
|
|
|
return frame == null ? null : ImageInfo(image: frame.image, scale: scale);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-28 17:43:58 +01:00
|
|
|
@override
|
|
|
|
|
Future<ui.Codec?> loadCodec() => throw UnsupportedError('Thumbhash does not support codec loading');
|
|
|
|
|
|
2025-08-20 15:36:44 -04:00
|
|
|
@override
|
2025-08-21 12:18:31 -05:00
|
|
|
void _onCancelled() {}
|
2025-08-20 15:36:44 -04:00
|
|
|
}
|