NodeViewModelState class

A view model state that represents a single node item in a json object tree. A decoded json object can be converted to a NodeViewModelState by calling the buildViewModelNodes method.

A node item can be eiter a class root, an array or a single class/array field.

The string key is the same as the json key, unless this node is an element if an array, then its key is its index in the array.

The node value behaviour depends on what this node represents, if it is a property (from json: "key": "value"), then the value is the actual property value, one of num, String, bool, Null. Since this node represents a single property, both isClass and isArray are false.

If this node represents a class, value contains a Map<String, NodeViewModelState> with this node's children. In this case isClass is true.

If this node represents an array, value contains a List<NodeViewModelState> with this node's children. In this case isArray is true.

See also:

Inheritance

Constructors

NodeViewModelState.fromArray({required int treeDepth, required String key, required NodeViewModelState? parent})
Build a NodeViewModelState as an array. An array is a JSON node containing an array of objects, each element inside the array is represented by another NodeViewModelState. Thus it can be values or classes. Its value is always a List<NodeViewModelState> containing the children information.
factory
NodeViewModelState.fromClass({required int treeDepth, required String key, required NodeViewModelState? parent})
Build a NodeViewModelState as a class. A class is a JSON node containing a whole class, a class can have multiple children properties, classes or arrays. Its value is always a Map<String, NodeViewModelState> containing the children information.
factory
NodeViewModelState.fromProperty({required int treeDepth, required String key, required dynamic value, required NodeViewModelState? parent})
Build a NodeViewModelState as a property. A property is a single attribute in the json, can be of a type num, String, bool or Null.
factory

Properties

children Iterable<NodeViewModelState>
Returns a list of this node's children.
no setter
childrenCount int
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
isArray bool
Flags if this node is an array, if true, then value is a List<NodeViewModelState>.
final
isClass bool
Flags if this node is a class, if true, then value is as Map<String, NodeViewModelState>.
final
isCollapsed bool
Returns true if this node is collapsed.
no setter
isFocused bool
Returns true if this node is focused.
no setter
isHighlighted bool
Returns true if this node is highlighted.
no setter
isRoot bool
Returns true if this is a root node.
no setter
key String
This attribute name.
final
parent NodeViewModelState?
A reference to the closest node above this one.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
treeDepth int
How deep in the tree this node is.
final
value ↔ dynamic
This attribute value, it may be one of the following: num, String, bool, Null, Map<String, NodeViewModelState> or List<NodeViewModelState>.
getter/setter pair

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
collapse() → void
Sets the isCollapsed property to false.
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
inherited
expand() → void
Sets the isCollapsed property to true.
focus({bool isFocused = true}) → void
Sets the focus property of this node.
highlight({bool isHighlighted = true}) → void
Sets the highlight property of this node and all of its children.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
toString() String
A string representation of this object.
inherited

Operators

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