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({
    'autofocus': false == autofocus ? null : autofocus,
    'clipBehavior': ThemeEncoder.encodeClip(
      clipBehavior,
    ),
    'focusNode': focusNode,
    'iconAlignment':
        IconAlignment.start == iconAlignment ? null : iconAlignment,
    'isSemanticButton': true == isSemanticButton ? null : isSemanticButton,
    'onFocusChange': onFocusChange,
    'onHover': onHover,
    'onLongPress': onLongPress,
    'onPressed': onPressed,
    'statesController': statesController,
    'style': ThemeEncoder.encodeButtonStyle(
      style,
    ),
    'child': child.toJson(),
    ...args,
  });
}