toJson method

Map<String, Object?> toJson()

Canonical JSON: fixed key order, absent fields left out.

Implementation

Map<String, Object?> toJson() => {
  if (families.isNotEmpty) 'families': [for (final f in families) f.name],
  if (brightness != null) 'brightness': brightness!.name,
  if (colors.isNotEmpty) 'colors': [for (final c in colors) c.word],
  if (chroma != null) 'chroma': chroma!.word,
  if (harmony != null) 'harmony': harmonyWords[harmony],
  if (hueRange != null) 'hueRange': [hueRange!.$1, hueRange!.$2],
  'name': ?name,
};