toJson method

Map<String, dynamic> toJson()

Converts the component to a JSON-serializable map.

Returns a map that can be serialized to JSON for the API request.

Implementation

Map<String, dynamic> toJson() {
  final Map<String, dynamic> json = {
    'type': _componentTypeToString(type),
  };

  if (subType != null) {
    json['sub_type'] = subType;
  }

  if (index != null) {
    json['index'] = index;
  }

  if (parameters.isNotEmpty) {
    json['parameters'] = parameters.map((p) => p.toJson()).toList();
  }

  return json;
}