TreeListAdapter<T> constructor
- {@required T root,
- @required T parentOf(
- T node
- @required int childrenCount(
- T node
- @required T childAt(
- T node,
- int index
- @required bool isNodeExpanded(
- T node
- @required int indexOfChild(
- T parent,
- T node
- bool equals(
- T nodeA,
- T nodeB
- bool includeRoot: true,
- int windowSize: _kWindowSize,
- int initialCount,
- int startingLevel: 0}
Creates a new tree adapter.
A root
node has to be specified.
The model consists of following callbacks:
parentOf
returns the parent node of a node;childrenCount
returns the number of the children of a node;childAt
returns the child node of a parent node at a specific position;isNodeExpanded
returns true if the node is expanded, false if it is collapsed;indexOfChild
returns the position of a child node;equals
returns true if two nodes are equals; if this callback is omitted, the == operator will be used;
If includeRoot
is set to true, the list view will also show the root node as the first item.
You can specify by windowSize
the size of the circular list used to cache the items.
You can also pass by initialCount
the initial count of all tree nodes if it is known,
to prevent the full scan of the tree in order to calculate its size.
Implementation
TreeListAdapter({
@required this.root,
@required this.parentOf,
@required this.childrenCount,
@required this.childAt,
@required this.isNodeExpanded,
@required this.indexOfChild,
this.equals = _kEquals,
this.includeRoot = true,
this.windowSize = _kWindowSize,
int initialCount,
this.startingLevel = 0,
}) : assert(root != null),
assert(parentOf != null),
assert(childrenCount != null),
assert(childAt != null),
assert(isNodeExpanded != null),
assert(indexOfChild != null),
assert(equals != null),
assert(includeRoot != null),
assert(windowSize != null),
assert(startingLevel != null),
_list = CircularList(windowSize) {
if (initialCount != null) {
assert(initialCount == count);
_count = initialCount;
}
}