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. Default pixelRatio is the device pixel ratio. 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.

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 PictureInfo that 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 canvas using the dimensions provided by size.
renderPosition(Canvas canvas, Vector2 position, Vector2 size) → void
Renders the svg on the canvas on the given position using the dimensions provided by size.
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 no cache is provided, the global Flame.assets is 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.