build method

  1. @override
InlineSpan build()
override

Implementation

@override
InlineSpan build() {
  List<TableRow> rows = [];

  int cellCount = 0;

  for (var child in children) {
    if (child is THeadNode) {
      cellCount = child.cellCount;
      rows.addAll(child.rows);
    } else if (child is TBodyNode) {
      rows.addAll(child.buildRows(cellCount));
    }
  }

  final tableWidget = Table(
    columnWidths: tbConfig.columnWidths,
    defaultColumnWidth: tbConfig.defaultColumnWidth ?? IntrinsicColumnWidth(),
    textBaseline: tbConfig.textBaseline,
    textDirection: tbConfig.textDirection,
    border: tbConfig.border ??
        TableBorder.all(
            color: parentStyle?.color ??
                config.p.textStyle.color ??
                Colors.grey),
    defaultVerticalAlignment: tbConfig.defaultVerticalAlignment ??
        TableCellVerticalAlignment.middle,
    children: rows,
  );

  return WidgetSpan(
      child: config.table.wrapper?.call(tableWidget) ?? tableWidget);
}