child method

Tree child(
  1. Object? item
)

Implementation

Tree child(Object? item) {
  switch (item) {
    case null:
      return this;

    case TreeChildren data:
      for (var i = 0; i < data.length; i++) {
        child(data.at(i));
      }
      return this;

    case List<dynamic> items:
      for (final it in items) {
        child(it);
      }
      return this;

    case Iterable<dynamic> items:
      for (final it in items) {
        child(it);
      }
      return this;

    case Tree t:
      return _appendTree(t);

    case TreeNode n:
      _children.add(n);
      return this;

    default:
      _children.add(_TreeLeaf(item.toString()));
      return this;
  }
}