toJson method

Map<String, Object?> toJson()

Implementation

Map<String, Object?> toJson() => {
  'type': sweep
      ? 'sweep'
      : radial
      ? 'radial'
      : 'linear',
  'colors': [for (final c in colors) c.toJson()],
  'stops': stops,
  if (!radial && !sweep) 'begin': [begin.$1, begin.$2],
  if (!radial && !sweep) 'end': [end.$1, end.$2],
  if (radial || sweep) 'center': [center.$1, center.$2],
  if (radial) 'radius': radius,
  if (sweep) 'rotation': rotation,
  if (size case (final w, final h)) 'size': [w, h],
};