toJson method

Map<String, dynamic> toJson()

Header encoded as JSON

Implementation

Map<String, dynamic> toJson() {
  final jsonMap = {
    'type': type,
    if (depth != null) 'depth': depth,
    if (identifier != null) 'identifier': identifier,
    if (width != null) 'width': width,
    if (height != null) 'height': height,
    if (x != null) 'x': x,
    if (y != null) 'y': y,
    if (z != null) 'z': z,
    if (visible != null) 'visible': visible,
    if (alpha != null) 'alpha': alpha,
    if (children.isNotEmpty)
      'children': children.map((e) => e.toJson()).toList(growable: false),
  };

  if (extra?.isNotEmpty ?? false) {
    jsonMap.addAll(extra!);
  }

  return jsonMap;
}