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() {
  final heroTagEncoded =
      _JsonFloatingActionButtonBuilder._encodeHeroTag(heroTag);

  return JsonClass.removeNull({
    'autofocus': false == autofocus ? null : autofocus,
    'backgroundColor': ThemeEncoder.encodeColor(
      backgroundColor,
    ),
    'clipBehavior': Clip.none == clipBehavior
        ? null
        : ThemeEncoder.encodeClip(
            clipBehavior,
          ),
    'disabledElevation': disabledElevation,
    'elevation': elevation,
    'enableFeedback': enableFeedback,
    'focusColor': ThemeEncoder.encodeColor(
      focusColor,
    ),
    'focusElevation': focusElevation,
    'focusNode': focusNode,
    'foregroundColor': ThemeEncoder.encodeColor(
      foregroundColor,
    ),
    'heroTag': '<default JsonWidget FloatingActionButton tag>' == heroTag
        ? null
        : heroTagEncoded,
    'highlightElevation': highlightElevation,
    'hoverColor': ThemeEncoder.encodeColor(
      hoverColor,
    ),
    'hoverElevation': hoverElevation,
    'isExtended': false == isExtended ? null : isExtended,
    'materialTapTargetSize': ThemeEncoder.encodeMaterialTapTargetSize(
      materialTapTargetSize,
    ),
    'mini': false == mini ? null : mini,
    'mouseCursor': ThemeEncoder.encodeMouseCursor(
      mouseCursor,
    ),
    'onPressed': onPressed,
    'shape': ThemeEncoder.encodeShapeBorder(
      shape,
    ),
    'splashColor': ThemeEncoder.encodeColor(
      splashColor,
    ),
    'tooltip': tooltip,
    'child': child?.toJson(),
    ...args,
  });
}