toJson method

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

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.

Implementation

@override
Map<String, dynamic> toJson() {
  //```codec
  const c = ColorCodec();
  //```
  return {
    'swatch': Colors.primaries.indexOf(swatch),
    'foreground': c.encode(foreground),
    'background': c.encode(background),
    //...surface
    '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),
    //...extras
    'success': c.encode(success),
    'error': c.encode(error),
    'warning': c.encode(warning),
    'tint': c.encode(tint),
    'shade': c.encode(shade),
  };
}