toJson method

  1. @override
Map<String, dynamic> toJson()

Convert this preset value to its encodable hashmap of String to it's encodable data. Override this method to declare how this field can be converted to it's encodable version.


Map<String, dynamic> toJson() {
  const c = ColorCodec();
  return {
    'swatch': Colors.primaries.indexOf(swatch),
    'foreground': c.encode(foreground),
    'background': c.encode(background),
    'primary': c.encode(primary),
    'secondary': c.encode(secondary),
    'ascent': c.encode(ascent),
    //...on surface
    'onPrimary': c.encode(onPrimary),
    'onSecondary': c.encode(onSecondary),
    'onAscent': c.encode(onAscent),
    'success': c.encode(success),
    'error': c.encode(error),
    'warning': c.encode(warning),
    'tint': c.encode(tint),
    'shade': c.encode(shade),