svgDataImageRender function

ImageRender svgDataImageRender()

Implementation

ImageRender svgDataImageRender() => (context, attributes, element) {
      final dataUri = _dataUriFormat.firstMatch(_src(attributes)!);
      final data = dataUri?.namedGroup('data');
      if (data == null) return null;
      if (dataUri?.namedGroup('encoding') == ';base64') {
        final decodedImage = base64.decode(data.trim());
        return SvgPicture.memory(
          decodedImage,
          width: _width(attributes),
          height: _height(attributes),
        );
      }
      return SvgPicture.string(Uri.decodeFull(data));
    };