Skip to content

Commit 4895884

Browse files
committed
[flame_svg] Fixed issues raised by Copilot in the PR #3956 review.
1 parent 907fc80 commit 4895884

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎packages/flame_svg/lib/svg.dart‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ class Svg {
3434
_integralSize = integralSize;
3535
_fixedRatio = fixedRatio;
3636
_cacheSize = cacheSize;
37-
_imageCache = MemoryCache(cacheSize: _cacheSize);
37+
assert(_cacheSize >= 1, 'The cache size must support at least one slot.');
38+
_imageCache = MemoryCache(
39+
cacheSize: _cacheSize >= 1 ? _cacheSize : defaultCacheSize,
40+
);
3841
}
3942

4043
/// The [PictureInfo] that this [Svg] represents.
@@ -64,7 +67,7 @@ class Svg {
6467
/// The current cache size (default 10): changing the size also empties it.
6568
int get cacheSize => _cacheSize;
6669
set cacheSize(int size) {
67-
assert(size >= 1, 'The cache size must contain at least one slot.');
70+
assert(size >= 1, 'The cache size must support at least one slot.');
6871
if (size >= 1 && size != cacheSize) {
6972
_emptyCache();
7073
_cacheSize = size;
@@ -176,7 +179,7 @@ class Svg {
176179
final height = size.height * heightRatio;
177180
Size cacheKey;
178181
if (fixedRatio || integralSize) {
179-
cacheKey = Size(width.roundToDouble(), height.roundToDouble());
182+
cacheKey = Size(width.ceilToDouble(), height.ceilToDouble());
180183
} else {
181184
cacheKey = Size(width, height);
182185
}

0 commit comments

Comments
 (0)