subTreeOf method

TreeListAdapter<T> subTreeOf (
  1. T node,
  2. [bool includeRoot = false,
  3. bool alwaysExpandRoot = true,
  4. bool keepCurrentLevel = true,
  5. int windowSize = _kWindowSize]
)

Returns a sub tree starting from the node.

If includeRoot is set to true, the root node will be considered as the first item.

If alwaysExpandRoot is set to true, the root node is considered expanded despite the callback isNodeExpanded callback.

If keepCurrentLevel is set to true, the node will keep its current level also in the subtree.

You can assign a new window size for the subtree specifying the attribute windowSize. If you set this to null, the subtree will inherit the same windowSize of this original tree.

Implementation

TreeListAdapter<T> subTreeOf(T node,
    [bool includeRoot = false,
    bool alwaysExpandRoot = true,
    bool keepCurrentLevel = true,
    int windowSize = _kWindowSize]) {
  final _this = this;
  return TreeListAdapter(
    root: node,
    parentOf: (n) => (equals(n, node)) ? null : _this.parentOf(n),
    childrenCount: childrenCount,
    childAt: childAt,
    isNodeExpanded: (n) => (alwaysExpandRoot && equals(n, node))
        ? true
        : _this.isNodeExpanded(n),
    indexOfChild: indexOfChild,
    equals: equals,
    includeRoot: includeRoot,
    windowSize: windowSize ?? this.windowSize,
    // initialCount: null,
    startingLevel:
        keepCurrentLevel ? (levelOf(node) + (includeRoot ? 0 : 1)) : 0,
  );
}