toJson method

  1. @override
Map<String, dynamic> toJson()

Abstract function that concrete classes must implement. This must encode the internal data model to a JSON compatible representation.

While not required, it is suggested to call removeNull before returning.

Implementation

@override
Map<String, dynamic> toJson() {
  final themeEncoded = _SvgBuilder._encodeSvgTheme(theme);

  return JsonClass.removeNull({
    'alignment': Alignment.center == alignment
        ? null
        : ThemeEncoder.encodeAlignment(
            alignment,
          ),
    'allowDrawingOutsideViewBox': false == allowDrawingOutsideViewBox
        ? null
        : allowDrawingOutsideViewBox,
    'asset': asset,
    'clipBehavior': Clip.hardEdge == clipBehavior
        ? null
        : ThemeEncoder.encodeClip(
            clipBehavior,
          ),
    'color': ThemeEncoder.encodeColor(
      color,
    ),
    'colorFilter': colorFilter,
    'excludeFromSemantics':
        false == excludeFromSemantics ? null : excludeFromSemantics,
    'fit': BoxFit.contain == fit
        ? null
        : ThemeEncoder.encodeBoxFit(
            fit,
          ),
    'headers': headers,
    'height': height,
    'image': image,
    'matchTextDirection': matchTextDirection,
    'package': package,
    'semanticsLabel': semanticsLabel,
    'theme': const SvgTheme() == theme ? null : themeEncoded,
    'url': url,
    'width': width,
    ...args,
  });
}