toJson method

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

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() {
  return JsonClass.removeNull({
    'alignment':
        Alignment.center == alignment
            ? null
            : ThemeEncoder.encodeAlignment(alignment),
    'cacheHeight': cacheHeight,
    'cacheWidth': cacheWidth,
    'centerSlice': ThemeEncoder.encodeRect(centerSlice),
    'color': ThemeEncoder.encodeColor(color),
    'colorBlendMode': ThemeEncoder.encodeBlendMode(colorBlendMode),
    'errorBuilder': errorBuilder,
    'excludeFromSemantics':
        false == excludeFromSemantics ? null : excludeFromSemantics,
    'filterQuality':
        FilterQuality.low == filterQuality
            ? null
            : ThemeEncoder.encodeFilterQuality(filterQuality),
    'fit': ThemeEncoder.encodeBoxFit(fit),
    'frameBuilder': frameBuilder,
    'gaplessPlayback': false == gaplessPlayback ? null : gaplessPlayback,
    'height': height,
    'image': image,
    'isAntiAlias': false == isAntiAlias ? null : isAntiAlias,
    'matchTextDirection':
        false == matchTextDirection ? null : matchTextDirection,
    'opacity': opacity,
    'repeat':
        ImageRepeat.noRepeat == repeat
            ? null
            : ThemeEncoder.encodeImageRepeat(repeat),
    'scale': 1.0 == scale ? null : scale,
    'semanticLabel': semanticLabel,
    'width': width,

    ...args,
  });
}