createTableContent function

List createTableContent(
  1. dynamic content,
  2. dynamic caption,
  3. dynamic head,
  4. dynamic body,
  5. dynamic foot, {
  6. bool? header,
  7. bool? footer,
})

Implementation

List createTableContent(content, caption, head, body, foot,
    {bool? header, bool? footer}) {
  if (content == null) {
    return [
      createTableCaption(caption),
      createTableEntry(head, header: true),
      createTableEntry(body),
      createTableEntry(foot, footer: true)
    ];
  }

  if (content is Iterable) {
    content = content.asList;
  }

  if (content is List) {
    if (listMatchesAll(content, (dynamic e) => _domHTML.isHtmlNode(e))) {
      var caption = content.firstWhere(
          (e) => _domHTML.getNodeTag(e) == 'caption',
          orElse: () => null);
      var thread = content.firstWhere((e) => _domHTML.getNodeTag(e) == 'thead',
          orElse: () => null);
      var tfoot = content.firstWhere((e) => _domHTML.getNodeTag(e) == 'tfoot',
          orElse: () => null);
      var tbody = content.firstWhere((e) => _domHTML.getNodeTag(e) == 'tbody',
          orElse: () => null);

      var list = <DOMNode?>[
        DOMNode.from(caption),
        DOMNode.from(thread),
        DOMNode.from(tbody),
        DOMNode.from(tfoot)
      ].nonNulls.toList();

      return list;
    } else {
      return content.map((e) => createTableEntry(e)).toList();
    }
  } else {
    return [createTableEntry(body)];
  }
}