TreeListAdapter<T> class
Adapter that takes a tree model as input and transforms it into a linear list view.
You must specify the data type T
of its nodes.
Constructors
- TreeListAdapter({@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): _kEquals, bool includeRoot: true, int windowSize: _kWindowSize, int initialCount, int startingLevel: 0})
-
Creates a new tree adapter.
A
root
node has to be specified. [...]
Properties
- childAt → T Function(T node, int index)
-
final
- childrenCount → int Function(T node)
-
final
- count → int
-
Returns the number of items required to show in a list view the entire tree.
read-only
- equals → bool Function(T nodeA, T nodeB)
-
final
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- includeRoot → bool
-
final
- indexOfChild → int Function(T parent, T node)
-
final
- isNodeExpanded → bool Function(T node)
-
final
- parentOf → T Function(T node)
-
final
- root ↔ T
-
read / write
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
- startingLevel → int
-
final
- windowSize → int
-
final
Methods
-
countSubTree(
T node) → int - Count how many items are required to show this node and its children in a list view, taking into account when a node is collapsed or not.
-
indexToNode(
int index) → T -
Returns the node underlying the list view item at position
index
. -
isLeaf(
T node) → bool -
Returns true if the
node
is a leaf node, that is without children. -
isRootNode(
T node) → bool -
Returns true if the
node
is the root node. The calback equals will be used. -
levelOf(
T node) → int -
Calculates the level of hierarchy of the
node
, taking into account the startingLevel. You can use this value to shift the widget's position right. -
nodeToIndex(
T node) → int -
Returns the index of the corresponding list view item for the
node
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
notifyNodeCollapsing(
T node, void collapseFn(), {int index, AnimatedListController controller, TreeItemBuilder< T> builder}) → Range -
This method has to be called when the
node
is about to be collapsed. Pass your function tocollapseFn
that takes care of actually collapsing the node. If you also have the index of the corresponding list view item, that's better pass it through theindex
attribute, otherwise you can just omit it. If you pass acontroller
, the linked animated list view will be automatically notified. In this case you have to indicate abuilder
to build the collapsed subtree. If you don't pass acontroller
, a Range will be returned to indicate the range of items of the list view involved in the modification. -
notifyNodeExpanding(
T node, void expandFn(), {int index, AnimatedListController controller}) → Range -
This method has to be called when the
node
is about to be expanded. Pass your function toexpandFn
that takes care of actually expanding the node. If you also have the index of the corresponding list view item, that's better pass it through theindex
attribute, otherwise you can just omit it. If you pass acontroller
, the linked animated list view will be automatically notified. If you don't pass acontroller
, a Range will be returned to indicate the range of items of the list view involved in the modification. -
notifyNodeInserting(
T newSubTree, T parentNode, int position, void insertFn(), {int index, AnimatedListController controller}) → Range -
This method has to be called when a new subtree
newSubTree
is about to be inserted as child of theparentNode
at the positionposition
. Pass your function toinsertFn
that takes care of actually inserting the node. If you also have the parent's index of the corresponding list view item, that's better pass it through theindex
attribute, otherwise you can just omit it. If you pass acontroller
, the linked animated list view will be automatically notified. If you don't pass acontroller
, a Range will be returned to indicate the range of items of the list view involved in the modification. -
notifyNodeRemoving(
T node, void removeFn(), {int index, AnimatedListController controller, TreeItemBuilder< T> builder}) → Range -
This method has to be called when the
node
is about to be removed. Pass your function toremoveFn
that takes care of actually removing the node. If you also have the index of the corresponding list view item, that's better pass it through theindex
attribute, otherwise you can just omit it. If you pass acontroller
, the linked animated list view will be automatically notified. In this case you have to indicate abuilder
to build the removed subtree. If you don't pass acontroller
, a Range will be returned to indicate the range of items of the list view involved in the modification. -
notifyTreeChanged(
T root, [int initialCount]) → void - Call this method when the tree has been completly changed.
-
subTreeOf(
T node, [bool includeRoot = false, bool alwaysExpandRoot = true, bool keepCurrentLevel = true, int windowSize = _kWindowSize]) → TreeListAdapter< T> -
Returns a sub tree starting from the
node
. [...] -
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator. [...]
inherited