perf(flutter): 사진을 그릴 크기로 줄여 메모리 사용을 줄임
CI (Flutter) / Flutter (analyze · test) (pull_request) Successful in 20m27s
CI / Backend (lint · test · e2e · build) (pull_request) Successful in 11m41s
CI / Frontend (lint · type-check · test) (pull_request) Successful in 10m47s
CI / 에러 코드 SSOT 동기화 검사 (pull_request) Successful in 11m8s
CI (Flutter) / Flutter (analyze · test) (push) Successful in 20m40s
CI / Backend (lint · test · e2e · build) (push) Successful in 12m4s
CI / Frontend (lint · type-check · test) (push) Successful in 10m55s
CI / 에러 코드 SSOT 동기화 검사 (push) Successful in 11m7s

공연(KOPIS) 포스터는 목록 썸네일도 원본이라(표본 15개 중앙 0.45MB · 최대 9.2MB) 그대로 풀면
사진 한 장에 수십 MB 를 쓴다. 그릴 크기 × 화면 배율로 가로를 정해 줄여 푼다(memCacheWidth).
cover 는 가로가 긴 사진도 세로를 채우도록 세로 × 2 까지 가로를 두고, 원본보다 크게 늘리지는 않는다.
내려받는 양은 그대로다(원본만 제공된다).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit was merged in pull request #5.
This commit is contained in:
2026-11-05 00:00:14 +09:00
parent c6017fd0ed
commit d4d99c9127
5 changed files with 118 additions and 11 deletions
@@ -0,0 +1,63 @@
import 'package:flutter/painting.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:wandergo/core/utils/image_decode.dart';
void main() {
group('decodeWidthFor', () {
test('cover 는 가로가 긴 사진도 세로를 채우도록 세로 × 2 까지 가로를 둔다', () {
// 목록 줄 64×64, 화면 배율 3 → max(64, 128) × 3
expect(
decodeWidthFor(
boxWidth: 64,
boxHeight: 64,
fit: BoxFit.cover,
devicePixelRatio: 3,
),
384,
);
// 함께 가기 카드 148×104 → max(148, 208) × 3
expect(
decodeWidthFor(
boxWidth: 148,
boxHeight: 104,
fit: BoxFit.cover,
devicePixelRatio: 3,
),
624,
);
});
test('contain(공공누리 Type3)은 상자 가로만큼이면 된다', () {
expect(
decodeWidthFor(
boxWidth: 148,
boxHeight: 104,
fit: BoxFit.contain,
devicePixelRatio: 2.625,
),
389,
);
});
test('가로를 모르면 세로로, 둘 다 모르면 null(원본 그대로)', () {
expect(
decodeWidthFor(
boxWidth: double.infinity,
boxHeight: 240,
fit: BoxFit.contain,
devicePixelRatio: 2,
),
960,
);
expect(
decodeWidthFor(
boxWidth: null,
boxHeight: double.infinity,
fit: BoxFit.cover,
devicePixelRatio: 2,
),
isNull,
);
});
});
}