SvgIcon class abstract final

Loads morphable icon data from SVG documents.

const logo = '<svg viewBox="0 0 24 24"><path d="M4 6h16"/></svg>';

MorphIcon(icon: SvgIcon.string(logo));                       // sync
final tick = await SvgIcon.asset('assets/icons/check.svg');  // async

SVGs drawn on different canvases still morph into each other: the root viewBox is honoured and the geometry is re-gridded onto a shared 24×24 space unless you pass fit: false.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

cacheSize int
Number of icons currently cached. Exposed for tests and diagnostics.
no setter

Static Methods

asset(String key, {AssetBundle? bundle, bool fit = true, double grid = 24}) Future<MorphIconData>
Loads an SVG bundled with the app (declared under assets: in your pubspec).
clearCache() → void
Empties the cache.
file(String path, {bool fit = true, double grid = 24}) Future<MorphIconData>
Loads an SVG from the file system.
memory(Uint8List bytes, {bool fit = true, double grid = 24, String? cacheKey}) MorphIconData
Parses SVG bytes — the response body of a request you made yourself, a blob from a database, an entry you pulled out of an archive.
network(Uri url, {Map<String, String>? headers, bool fit = true, double grid = 24}) Future<MorphIconData>
Fetches an SVG over HTTP.
string(String svg, {bool fit = true, double grid = 24}) MorphIconData
Parses SVG markup you already have as a string.