toJson method

Implementation

@override
MapEntry<String, Map<String, Object?>> toJson(DesignToken value) {
  final description = value.description;
  return MapEntry(
    value.name,
    {
      if (description != null) 'description': description,
      'value': () {
        return value.value.map(
          unknown: (value) => null,
          dimension: (value) => value.value,
          spacing: (value) =>
              const SpacingTokenValueConverter().toJson(value),
          radius: (value) => const RadiusTokenValueConverter().toJson(value),
          color: (value) => const ColorTokenValueConverter().toJson(value),
          fontStyle: (value) =>
              const FontStyleTokenValueConverter().toJson(value),
          icon: (value) => const IconTokenValueConverter().toJson(value),
        );
      }(),
    },
  );
}