createTableContent function

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

Implementation

List createTableContent(
  Object? content,
  Object? caption,
  Object? head,
  Object? body,
  Object? 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)];
  }
}