toJson method
Serializes this element to VPS-compatible JSON.
Implementation
Map<String, dynamic> toJson() => {
'id': id,
'type': type.name,
'x': x,
'y': y,
'width': width,
'height': height,
'value': value,
'fontSize': fontSize,
'bold': bold,
'textAlign': textAlign,
'fontFamily': fontFamily,
'printColor': printColor,
'band': band,
if (visibilityCondition.isNotEmpty)
'visibilityCondition': visibilityCondition,
if (pageVisibility != ElementPageVisibility.all)
'pageVisibility': pageVisibility.name,
if (locked) 'locked': true,
if (hidden) 'hidden': true,
if (keepTogether) 'keepTogether': true,
if (flow) 'flow': true,
if (section != 'body') 'section': section,
if (type == ElementType.table) ...{
'dataSource': dataSource,
'columns': columns.map((column) => column.toJson()).toList(),
'rowHeight': rowHeight,
'headerColor': headerColor,
'headerTextColor': headerTextColor,
'alternateRowColor': alternateRowColor,
'showBorders': showBorders,
if (groupBy.isNotEmpty)
'grouping': {
'field': groupBy,
'header': groupHeader,
'footer': groupFooter,
'showHeader': showGroupHeader,
'showFooter': showGroupFooter,
},
'summary': {
'enabled': showSummary,
'showSubtotal': showSubtotal,
'showTaxes': showTaxes,
'amountExpression': amountExpression,
'subtotalLabel': subtotalLabel,
'discountPercent': discountPercent,
'discountLabel': discountLabel,
'totalLabel': totalLabel,
'taxRules': taxRules.map((rule) => rule.toJson()).toList(),
'aggregateRules': aggregateRules.map((rule) => rule.toJson()).toList(),
},
},
if (type == ElementType.chart) ...{
'dataSource': dataSource,
'chart': {
'type': chartType.name,
'categoryField': chartCategoryField,
'valueExpression': chartValueExpression,
'colors': chartColors,
'showLegend': chartShowLegend,
'showLabels': chartShowLabels,
},
},
if (type == ElementType.image) ...{
'imageBase64': imageBase64,
'imageName': imageName,
'imageFit': imageFit,
},
if (type == ElementType.line) ...{
'lineDirection': lineDirection,
'lineThickness': lineThickness,
},
if (type == ElementType.qrCode || type == ElementType.eanCode) ...{
'codeValue': codeValue,
'barcodeType': barcodeType,
'showCodeText': showCodeText,
},
};