ScalableImageSource class abstract
An asynchronous source of a ScalableImage. This is used for asynchronous loading of an SI asset by a ScalableImageWidget, e.g from an AssetBundle. This class may be subclassed by clients of this library, e.g. for loading from other network sources.
If new subclasses are written, attention is drawn to the need to implement
operator ==
and hashCode
.
Constructors
Properties
- asKey → ScalableImageSource
-
Give an object that is suitable for storing as the key in a Map for
this source. The returned object must be
==
this (it must compare as equivalent), and it must have the samehashCode
as this. It should have any extra fields stripped off that might cause large amounts of object retention. For example, if warnF is retained as a field, it could be a closure that retains arbitrary state, so it should not be retained.no setter - hashCode → int
-
Compute the hash code for this source. Subclasses must override this,
so that different instances of equivalent sources give the same hash
code. This will avoid unnecessary rebuilding of ScalableImage
objects.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
si
→ Future<
ScalableImage> -
Get the ScalableImage from this source. If called multiple times, it is
unspecified if the same Future instance is returned or not. Subclasses
need not override this method. The default implementation throws a
StateError. See createSI.
no setter
- warn → bool
-
Flag to tell if warnings should be printed if there is a problem
loading this asset. For released products, the subclass should have
a mechanism to set this false. The default version of this getter always
returns true.
no setter
- warnF → void Function(String)?
-
Function to call to warn if there is a problem
loading this asset. The default version of this getter always
returns null. If it is null, the default
behavior is to print warnings.
no setter
Methods
-
createSI(
) → Future< ScalableImage> - Create a new future that will return a ScalableImage from this source. It is normally expected that a new future that returns a new image will be returned from each call, but this is not a requirement. This method must be overridden by subclasses.
-
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 -
Compare this source to another. Subclasses must override this, so that
different instances of equivalent sources give true. This avoids
unnecessary rebuilding of ScalableImage objects.
override
Static Methods
-
fromAvd(
AssetBundle bundle, String key, {bool compact = false, bool bigFloats = false, bool warn = true, void warnF(String)?}) → ScalableImageSource - Get a ScalableImage by parsing an Android Vector Drawable XML file from an asset bundle. In a production app, it's better to pre-compile the file -- see ScalableImageSource.fromSI
-
fromAvdHttpUrl(
Uri url, {Color? currentColor, bool compact = false, bool bigFloats = false, bool warn = true, void warnF(String)?, Map< String, String> ? httpHeaders, Encoding defaultEncoding = utf8}) → ScalableImageSource - Get a ScalableImage by parsing an AVD XML file from a http:, https: or data: URL.
-
fromSI(
AssetBundle bundle, String key, {Color? currentColor}) → ScalableImageSource -
Get a ScalableImage by reading a pre-compiled
.si
file. These files can be produced withdart run jovial_svg:svg_to_si
ordart run jovial_svg:avd_to_si
. Pre-compiled files load about an order of magnitude faster. -
fromSvg(
AssetBundle bundle, String key, {Color? currentColor, bool compact = false, bool bigFloats = false, bool warn = true, void warnF(String)?, List< Pattern> exportedIDs = const []}) → ScalableImageSource - Get a ScalableImage by parsing an SVG XML file from an asset bundle. In a production app, it's better to pre-compile the file -- see ScalableImageSource.fromSI
-
fromSvgFile(
Object file, FutureOr< String> fileReader(), {Color? currentColor, bool compact = false, bool bigFloats = false, void warnF(String)?, List<Pattern> exportedIDs = const []}) → ScalableImageSource -
Get a ScalableImage by parsing an SVG XML file from
a
File
, from the dart:io library.File
isn't available on Dart Web, so theFile
argument is passed as an object, along with a a function to read a string from it. -
fromSvgHttpUrl(
Uri url, {Color? currentColor, bool compact = false, bool bigFloats = false, bool warn = true, void warnF(String)?, List< Pattern> exportedIDs = const [], Map<String, String> ? httpHeaders, Encoding defaultEncoding = utf8}) → ScalableImageSource - Get a ScalableImage by parsing an SVG XML file from a http:, https: or data: URL.