feat: add characters
This commit is contained in:
@@ -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;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user