parse method

void parse(
  1. String jsonContent
)

Parses JSON content and builds the receipt layout.

Takes a jsonContent string containing the receipt data in JSON format and processes it to populate the layoutReceipt list with widgets.

Supports special keys:

  • 'header': Creates a header section with optional image
  • 'footer': Creates a footer section with optional image
  • 'line': Creates a regular line item

Implementation

void parse(String jsonContent) {
  final List<dynamic> jsonData = json.decode(jsonContent) as List;
  for (final data in jsonData) {
    if (data.containsKey('header')) {
      final List<dynamic> header = data['header'] as List;
      _buildFixedLayout(header, GenericType.HEADER);
    } else if (data.containsKey('footer')) {
      final List<dynamic> footer = data['footer'] as List;
      _buildFixedLayout(footer, GenericType.FOOTER);
    } else {
      layoutReceipt.addAll(_buildLine(data));
    }
  }
}