copyWith method

TreeNode<T> copyWith({
  1. String? key,
  2. T? data,
  3. bool? expanded,
  4. bool? selected,
  5. bool? reorderable,
  6. TreeNode<T>? parent,
  7. List<TreeNode<T>>? children,
})

Implementation

TreeNode<T> copyWith(
    {String? key,
    T? data,
    bool? expanded,
    bool? selected,
    bool? reorderable,
    TreeNode<T>? parent,
    List<TreeNode<T>>? children}) {
  var copyNode = TreeNode(
    key: key ?? this.key,
    data: data ?? this.data,
    expanded: expanded ?? this.expanded,
    reorderable: reorderable ?? this.reorderable,
    parent: parent ?? _parent,
  );
  _children?.forEach((element) {
    copyNode.children.add(element.copyWith(parent: copyNode));
  });
  return copyNode;
}