fromSvgHttpUrl static method

Future<ScalableImage> fromSvgHttpUrl(
  1. Uri url, {
  2. bool compact = false,
  3. bool bigFloats = false,
  4. @Deprecated("[warn] has been superseded by [warnF].") bool warn = true,
  5. void warnF(
    1. String
    )?,
  6. Color? currentColor,
  7. Encoding defaultEncoding = utf8,
  8. Map<String, String>? httpHeaders,
})

Parse an SVG XML document from a URL to a scalable image. Usage:

final si = await ScalableImage.fromSvgHttpUrl(
    Uri.parse('https://jovial.com/images/jupiter.svg'));

url is an http:, https: or data: Uri

If compact is true, the internal representation will occupy significantly less memory, at the expense of rendering time. See toDag for a discussion of the two representations.

If bigFloats is true, the compact representation will use 8 byte double-precision float values, rather than 4 byte single-precision values.

If warnF is non-null, it will be called if the SVG asset contains unrecognized tags and/or tag attributes. If it is null, the default behavior is to print warnings.

httpHeaders will be added to the HTTP GET request.

defaultEncoding specifies the character encoding to use if the content-type header of the HTTP response does not indicate an encoding. RVC 2916 specifies latin1 for HTTP, but current browser practice defaults to UTF8.

See also ScalableImage.currentColor.

Implementation

static Future<ScalableImage> fromSvgHttpUrl(
  Uri url, {
  bool compact = false,
  bool bigFloats = false,
  @Deprecated("[warn] has been superseded by [warnF].") bool warn = true,
  void Function(String)? warnF,
  Color? currentColor,
  Encoding defaultEncoding = utf8,
  Map<String, String>? httpHeaders,
}) async {
  final warnArg = warnF ?? (warn ? defaultWarn : nullWarn);
  return fromSvgString(await _getContent(url, defaultEncoding, httpHeaders),
      compact: compact,
      bigFloats: bigFloats,
      warnF: warnArg,
      currentColor: currentColor);
}