feat: add carpet
This commit is contained in:
@@ -57,6 +57,22 @@ class CardImages {
|
||||
}
|
||||
}
|
||||
|
||||
/// تصویرِ فرش (برای سطحِ میز) از backend: `/carpets/<id>.jpg`. کششده.
|
||||
static Future<Sprite?> carpet(String id) {
|
||||
return _cache.putIfAbsent('carpet/$id', () async {
|
||||
try {
|
||||
final res = await _dio
|
||||
.get<List<int>>('${AppConfig.baseUrl}/carpets/$id.jpg');
|
||||
final data = res.data;
|
||||
if (data == null || data.isEmpty) return null;
|
||||
return Sprite(await _decode(Uint8List.fromList(data)));
|
||||
} catch (e) {
|
||||
debugPrint('CardImages: carpet/$id failed: $e');
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static Future<ui.Image> _decode(Uint8List bytes) async {
|
||||
final codec = await ui.instantiateImageCodec(bytes);
|
||||
final frame = await codec.getNextFrame();
|
||||
|
||||
Reference in New Issue
Block a user