Svg class
A Svg to be rendered on a Flame Game.
Constructors
- Svg(PictureInfo pictureInfo, {double? pixelRatio, bool fixedRatio = false, int cacheSize = defaultCacheSize})
-
Creates an Svg with the received
pictureInfo. DefaultpixelRatiois the device pixel ratio. SettingfixedRatiototrueensures the cache uses one entry per rendered size/scale. DefaultcacheSizeis defaultCacheSize, which is 10 as previously; specifying unlimitedCacheSize is the same as using a Map instead of aMemoryCache.
Properties
- cacheSize ↔ int
-
The current cache size (default 10): changing the size also empties it.
getter/setter pair
- cacheUsage → int
-
The number of images currently used by the cache.
no setter
- fixedRatio ↔ bool
-
Whether we're using a fixed ratio for the cache keys (default: false).
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- pictureInfo → PictureInfo
-
The
PictureInfothat this Svg represents.final - pixelRatio → double
-
The pixel ratio that this Svg is rendered based on.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
dispose(
) → void - Clear all the stored cache from this SVG, be sure to call this method once the instance is no longer needed to avoid memory leaks
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
render(
Canvas canvas, Vector2 size, {Paint? overridePaint}) → void -
Renders the svg on the
canvasusing the dimensions provided bysize. -
renderPosition(
Canvas canvas, Vector2 position, Vector2 size) → void -
Renders the svg on the
canvason the givenpositionusing the dimensions provided bysize. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- unlimitedCacheSize → int
-
Unlimited memory cache size.
final
Static Methods
-
load(
String fileName, {AssetsCache? cache, double? pixelRatio, bool fixedRatio = false, int cacheSize = defaultCacheSize, String? package}) → Future< Svg> -
Loads an Svg with the received
cache. When nocacheis provided, the globalFlame.assetsis used. -
loadFromString(
String svgString, {double? pixelRatio, bool fixedRatio = false, int cacheSize = defaultCacheSize}) → Future< Svg> - Loads an Svg from a string.
Constants
- defaultCacheSize → const int
- Default memory cache size.