Graph<E> class

The main class the capsulates all the data and all the functions needed to calculate node positions please use this OrgChartController class instead of Graph, as i want to rename that class in a future version

Inheritance
Annotations
  • @Deprecated("Please use [OrgChartController] instead of this class, as i want to rename this class in a future")

Constructors

Graph({required List<E> items, required String? idProvider(E data), required String? toProvider(E data), Size boxSize = const Size(200, 100), Offset spacing = const Offset(20, 50), OrgChartOrientation orientation = OrgChartOrientation.leftToRight})

Properties

boxSize Size
The size of each node box. Needed to determine it here and not in the contentBuilder function because I need this value for the calculations
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
idProvider String? Function(E data)
The following function is included to ease the use of custom data types whether it be a map with key 'id' or 'pk' or a custom class, just use this function to provide the ids The function that returns the id of the node.
getter/setter pairinherited
items List<E>
returns the list of items showed in the graph use the remove item if you want to remove an item from the list
getter/setter pairinherited
orientation OrgChartOrientation
getter/setter pairinherited
roots List<Node<E>>
returns the list of root nodes
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
spacing Offset
The spacing between each node box. Needed here for the same reason i need boxSize here.
getter/setter pairinherited
toProvider String? Function(E data)
The following function is included to ease the use of custom data types whether it be a map with key 'id' or 'pk' or a custom class, just use this function to provide the ids The function that returns the id of the node that the current node is pointing to.
getter/setter pairinherited
uniqueNodeId String
to generate a unique id for an item this is used when you want to add an item to the list and you don't want to provide an id for it you might want to get an id from the server, but in case of a local list you can use this function
no setterinherited

Methods

addItem(E item) → void
to add an item to the list position will be calculated afterwards
inherited
allLeaf(List<Node<E>> nodes) bool
returns true if all the nodes in the list are leaves nodes
inherited
calculatePosition() → void
call this function when you want to recalculate the positions of the nodes for example if you want to restore the postion after dragging the items around but don't forget to setState after calcutions this function is called automatically when you change the items list
inherited
changeNodeIndex(Node<E> node, dynamic index) → void
changes the index of the node in the list, if index is -1 then it will be moved to the end of the list this is used on drag start to move the dragged node to the end of the list so that it will be drawn on top
inherited
getOverlapping(Node<E> node) List<Node<E>>
input: the node that we want to get the overlapping nodes with returns a list of nodes that are overlapping with the input node sorted by closest to farthest from the input node
inherited
getSize({Offset offset = const Offset(0, 0)}) Offset
returns the total size of the graph
inherited
getSubNodes(Node<E> node) List<Node<E>>
returns the list of nodes that are pointing to the input node
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeItem(dynamic id) → void
to remove an item from the list
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited