IndexedNode class

Inheritance
Implemented types
Implementers

Constructors

IndexedNode({String? key, IndexedNode? parent})
The more comprehensive variant of Node that uses List to store the children.
IndexedNode.root()
Alternate factory constructor that should be used for the root nodes.
factory

Properties

children List<IndexedNode>
These are the children of the node.
final
childrenAsList List<IndexedNode>
This returns the children as an iterable list.
no setteroverride
first IndexedNode
Get the first child in the list
getter/setter pairoverride
hashCode int
The hash code for this object.
no setterinherited
isLeaf bool
Getter to check if the node is a Leaf. A Leaf-Node does have any children.
no setterinherited
isRoot bool
Getter to check if the node is a root. Root is always the first node in a Tree. A Root-Node never has a parent.
no setterinherited
key String
This is the uniqueKey of the Node
final
last IndexedNode
Get the last child in the list
getter/setter pairoverride
length int
Getter to get the total number of children
no setterinherited
level int
Getter to get the level i.e. how many iterations it will take to get to the root. ** Note: starting index is 0.
no setterinherited
meta Map<String, dynamic>?
Any related data that needs to be accessible from the node can be added to meta without needing to extend or implement the INode
getter/setter pairoverride
parent IndexedNode?
This is the parent Node. Only the root node has a null parent
covariantgetter/setter pairoverride
path String
Path of the node in the tree. It provides information about the node hierarchy by listing all the ancestors of the node.
no setterinherited
root IndexedNode
Getter to get the root node. If the current node is not a root, then the getter will traverse up the path to get the root.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(covariant IndexedNode value) → void
Add a child value node to the children. The value will be inserted after the last child in the list
override
addAll(covariant Iterable<IndexedNode> iterable) → void
Add a collection of Iterable nodes to children. The iterable will be inserted after the last child in the list
override
at(int index) IndexedNode
Returns the child node at the index
override
clear() → void
Clear all the child nodes from children. The children will be empty after this operation.
override
delete() → void
Delete this node
override
elementAt(String path) IndexedNode
  • Utility method to get a child node at the path. Get any item at path from the root The keys of the items to be traversed should be provided in the path
  • override
    firstWhere(bool test(IndexedNode element), {IndexedNode orElse()?}) IndexedNode
    Get the first child node that matches the criterion in the test. An optional orElse function can be provided to handle the test is not able to find any node that matches the provided criterion.
    override
    indexWhere(bool test(IndexedNode element), [int start = 0]) int
    Get the index of the first child node that matches the criterion in the test. An optional start index can be provided to ignore any nodes before the index start
    override
    insert(int index, IndexedNode element) → void
    Insert an element in the children list at index
    override
    insertAfter(IndexedNode after, IndexedNode element) int
    Insert an element in the children list after the node after
    override
    insertAll(int index, Iterable<IndexedNode> iterable) → void
    Insert a collection of Iterable nodes in the children list at index
    override
    insertBefore(IndexedNode before, IndexedNode element) int
    Insert an element in the children list before the node before
    override
    lastWhere(bool test(IndexedNode element), {IndexedNode orElse()?}) IndexedNode
    Get the last child node that matches the criterion in the test. An optional orElse function can be provided to handle the test is not able to find any node that matches the provided criterion.
    override
    noSuchMethod(Invocation invocation) → dynamic
    Invoked when a nonexistent method or property is accessed.
    inherited
    remove(covariant IndexedNode value) → void
    Remove a child value node from the children
    override
    removeAll(covariant Iterable<IndexedNode> iterable) → void
    Remove all the Iterable nodes from the children
    override
    removeAt(int index) IndexedNode
    Remove the child node at the index
    override
    removeWhere(bool test(IndexedNode element)) → void
    Remove all the child nodes from the children that match the criterion in the given test
    override
    toString() String
    A string representation of this object.
    override

    Operators

    operator ==(Object other) bool
    The equality operator.
    inherited
    operator [](String path) IndexedNode
    Overloaded operator for elementAt
    override