diff --git a/packages/flame_svg/lib/svg.dart b/packages/flame_svg/lib/svg.dart index f6eb4829d24..a919c83723d 100644 --- a/packages/flame_svg/lib/svg.dart +++ b/packages/flame_svg/lib/svg.dart @@ -12,15 +12,14 @@ import 'package:flutter_svg/flutter_svg.dart'; class Svg { /// Creates an [Svg] with the received [pictureInfo]. /// Default [pixelRatio] is the device pixel ratio. - /// Setting [integralSize] to `true` uses integer dimensions for cache keys. - /// Setting [fixedRatio] to `true` ensures the cache uses a single entry. + /// Setting [fixedRatio] to `true` ensures the cache uses one entry + /// per rendered size/scale. /// Default [cacheSize] is [defaultCacheSize], which is 10 as previously; /// specifying [unlimitedCacheSize] is the same as using a [Map] instead /// of a [MemoryCache]. Svg( this.pictureInfo, { double? pixelRatio, - bool integralSize = false, bool fixedRatio = false, int cacheSize = defaultCacheSize, }) : pixelRatio = @@ -31,7 +30,6 @@ class Svg { .views .first .devicePixelRatio { - _integralSize = integralSize; _fixedRatio = fixedRatio; _cacheSize = cacheSize; assert(_cacheSize >= 1, 'The cache size must support at least one slot.'); @@ -46,15 +44,6 @@ class Svg { /// The pixel ratio that this [Svg] is rendered based on. final double pixelRatio; - /// Whether we're using integral sizes for the cache keys (default: false). - bool get integralSize => _integralSize; - set integralSize(bool integral) { - _emptyCache(); - _integralSize = integral; - } - - late bool _integralSize; - /// Whether we're using a fixed ratio for the cache keys (default: false). bool get fixedRatio => _fixedRatio; set fixedRatio(bool fixed) { @@ -90,7 +79,6 @@ class Svg { String fileName, { AssetsCache? cache, double? pixelRatio, - bool integralSize = false, bool fixedRatio = false, int cacheSize = defaultCacheSize, String? package, @@ -100,7 +88,6 @@ class Svg { return Svg.loadFromString( svgString, pixelRatio: pixelRatio, - integralSize: integralSize, fixedRatio: fixedRatio, cacheSize: cacheSize, ); @@ -110,7 +97,6 @@ class Svg { static Future loadFromString( String svgString, { double? pixelRatio, - bool integralSize = false, bool fixedRatio = false, int cacheSize = defaultCacheSize, }) async { @@ -118,7 +104,6 @@ class Svg { return Svg( pictureInfo, pixelRatio: pixelRatio, - integralSize: integralSize, fixedRatio: fixedRatio, cacheSize: cacheSize, ); @@ -177,12 +162,7 @@ class Svg { Image _getImage(Size size, double widthRatio, double heightRatio) { final width = size.width * widthRatio; final height = size.height * heightRatio; - Size cacheKey; - if (fixedRatio || integralSize) { - cacheKey = Size(width.ceilToDouble(), height.ceilToDouble()); - } else { - cacheKey = Size(width, height); - } + final cacheKey = Size(width.ceilToDouble(), height.ceilToDouble()); final image = _imageCache.getValue(cacheKey); if (image == null) { @@ -239,14 +219,12 @@ extension SvgLoader on Game { Future loadSvg( String fileName, { String? package, - bool integralSize = false, bool fixedRatio = false, int cacheSize = Svg.defaultCacheSize, }) => Svg.load( fileName, cache: assets, package: package, - integralSize: integralSize, fixedRatio: fixedRatio, cacheSize: cacheSize, );