toJson method

Map<String, Object> toJson()

Validates and serializes appearance for the native bridge.

Implementation

Map<String, Object> toJson() {
  _validateColor('primaryColor', primaryColor);
  _validateColor('backgroundColor', backgroundColor);
  _validateColor('textColor', textColor);
  final radius = cornerRadius;
  if (radius != null && (!radius.isFinite || radius < 0 || radius > 40)) {
    throw ArgumentError.value(
      radius,
      'cornerRadius',
      'must be between 0 and 40',
    );
  }

  return {
    'primaryColor': ?primaryColor,
    'backgroundColor': ?backgroundColor,
    'textColor': ?textColor,
    'cornerRadius': ?radius,
  };
}