fromJson method

Implementation

@override
DesignToken fromJson(MapEntry<String, Map<String, Object?>> json) {
  final name = json.value['name'];
  final type = json.value['type'];
  final value = json.value['value'];
  return DesignToken(
    name: json.key,
    description: name is String ? name : null,
    value: () {
      if (type is String) {
        switch (type) {
          case 'dimension':
            return DesignTokenValue.dimension(
                value is num ? value.toDouble() : 0.0);
          case 'color':
            return const ColorTokenValueConverter().fromJson(value);
          case 'custom-spacing':
            return const SpacingTokenValueConverter().fromJson(value);
          case 'custom-radius':
            return const RadiusTokenValueConverter().fromJson(value);
          case 'custom-fontStyle':
            return const FontStyleTokenValueConverter().fromJson(value);
          case 'custom-icon':
            return const IconTokenValueConverter().fromJson(value);
          default:
            return const DesignTokenValue.unknown();
        }
      }

      return const DesignTokenValue.unknown();
    }(),
  );
}