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({
    'activeColor': ThemeEncoder.encodeColor(
      activeColor,
    ),
    'autovalidateMode': ThemeEncoder.encodeAutovalidateMode(
      autovalidateMode,
    ),
    'dragStartBehavior': ThemeEncoder.encodeDragStartBehavior(
      dragStartBehavior,
    ),
    'enabled': true == enabled ? null : enabled,
    'label': label,
    'onChanged': onChanged,
    'onSaved': onSaved,
    'restorationId': restorationId,
    'thumbColor': ThemeEncoder.encodeColor(
      thumbColor,
    ),
    'trackColor': ThemeEncoder.encodeColor(
      trackColor,
    ),
    'validators': validators,
    'value': false == value ? null : value,
    'visualDensity': ThemeEncoder.encodeVisualDensity(
      visualDensity,
    ),
    ...args,
  });
}