feat: add characters

This commit is contained in:
2026-07-10 00:56:58 +03:30
parent 7c067d36f2
commit 97d156c492
28 changed files with 486 additions and 94 deletions
+6 -6
View File
@@ -57,17 +57,17 @@ class CardImages {
}
}
/// تصویرِ فرش (برای سطحِ میز) از backend: `/carpets/<id>.jpg`. کش‌شده.
static Future<Sprite?> carpet(String id) {
return _cache.putIfAbsent('carpet/$id', () async {
/// تصویرِ فرش (برای سطحِ میز) از URL کاملِ backend. کش‌شده با کلیدِ URL.
static Future<Sprite?> carpetByUrl(String url) {
if (url.isEmpty) return Future.value(null);
return _cache.putIfAbsent('carpet/$url', () async {
try {
final res = await _dio
.get<List<int>>('${AppConfig.baseUrl}/carpets/$id.jpg');
final res = await _dio.get<List<int>>(url);
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');
debugPrint('CardImages: carpet $url failed: $e');
return null;
}
});