applyTableMarkers function

void applyTableMarkers(
  1. List<FluentRow> rows
)

Implementation

void applyTableMarkers(List<FluentRow> rows) {
  // remove all existing markers
  for (final row in rows) {
    for (final cell in row.cells) {
      for (final frag in cell.fragments.whereType<Fragment>()) {
        frag.text = frag.text.replaceAll(Whitespaces.zws, '');
      }
    }
  }

  final allCells = rows.expand((r) => r.cells).toList();
  if (allCells.length <= 1) return;

  for (int i = 0; i < allCells.length; i++) {
    final frags = allCells[i].fragments.whereType<Fragment>().toList();
    if (frags.isEmpty) continue;

    if (i == 0) {
      frags.last.text = '${frags.last.text}${Whitespaces.zws}';
    } else if (i == allCells.length - 1) {
      frags.first.text = '${Whitespaces.zws}${frags.first.text}';
    } else {
      frags.first.text = '${Whitespaces.zws}${frags.first.text}';
      frags.last.text = '${frags.last.text}${Whitespaces.zws}';
    }
  }
}