from static method

Widget from(
  1. BuildContext context,
  2. List<TKeyValue> values, {
  3. TPdfTableDecoration decoration = const TPdfTableDecoration(),
  4. double availableWidth = 515,
  5. TKeyValueTheme? theme,
  6. Map<String, Uint8List>? imageCache,
  7. double gridSpacing = 0,
})

Creates a grid layout from a list of TKeyValue items.

Implementation

static pw.Widget from(
  BuildContext context,
  List<TKeyValue> values, {
  TPdfTableDecoration decoration = const TPdfTableDecoration(),
  double availableWidth = 515,
  TKeyValueTheme? theme,
  Map<String, Uint8List>? imageCache,
  double gridSpacing = 0,
}) {
  final colors = context.colors;
  final wTheme = theme ?? TKeyValueTheme.defaultTheme(colors);

  final gridData = _createRowData(values, wTheme, availableWidth);

  return pw.Column(
    crossAxisAlignment: pw.CrossAxisAlignment.start,
    children: gridData.map((rowData) {
      return pw.Padding(
        padding: pw.EdgeInsets.only(bottom: gridSpacing),
        child: pw.Table(
          columnWidths: _createColumnWidths(rowData.columnWidths),
          children: [
            pw.TableRow(
              children: rowData.values.asMap().entries.map((entry) {
                final index = entry.key;
                final keyValue = entry.value;
                final isFirst = index == 0;

                return _buildGridCell(colors, wTheme, decoration, keyValue, isFirst, imageCache: imageCache);
              }).toList(),
            ),
          ],
        ),
      );
    }).toList(),
  );
}