createTableRow function

TRowElement createTableRow(
  1. Object? rowCells, [
  2. bool? header
])

Implementation

TRowElement createTableRow(Object? rowCells, [bool? header]) {
  header ??= false;

  if (rowCells is TRowElement) {
    return rowCells;
  }

  Iterable iterable;

  if (rowCells is Iterable) {
    iterable = List.from(rowCells);
  } else {
    iterable = [rowCells];
  }

  var tr = TRowElement();

  if (header) {
    for (var e in iterable) {
      if (e is THElement) {
        tr.add(e);
      } else if (e is TDElement) {
        tr.add(e.asTHElement());
      } else {
        tr.addAsTag('th', e);
      }
    }
  } else {
    for (var e in iterable) {
      if (e is TDElement) {
        tr.add(e);
      } else if (e is THElement) {
        tr.add(e.asTDElement());
      } else {
        tr.addAsTag('td', e);
      }
    }
  }

  return tr;
}