obtainKey method
Converts an ImageProvider's settings plus an ImageConfiguration to a key that describes the precise image to load.
The type of the key is determined by the subclass. It is a value that unambiguously identifies the image (including its scale) that the loadImage method will fetch. Different ImageProviders given the same constructor arguments and ImageConfiguration objects should return keys that are '==' to each other (possibly by using a class for the key that itself implements ==).
If the result can be determined synchronously, this function should return a SynchronousFuture. This allows image resolution to progress synchronously during a frame rather than delaying image loading.
Implementation
@override
Future<SvgImageKey> obtainKey(ImageConfiguration configuration) {
final Color color = getFilterColor(this.color);
final double scale = this.scale ?? configuration.devicePixelRatio ?? 1.0;
final double logicWidth = size?.width ?? configuration.size?.width ?? 100;
final double logicHeight = size?.height ?? configuration.size?.height ?? 100;
return SynchronousFuture<SvgImageKey>(
SvgImageKey(
path: path,
scale: scale,
color: color,
source: source,
pixelWidth: (logicWidth * scale).round(),
pixelHeight: (logicHeight * scale).round(),
svgGetter: svgGetter,
),
);
}