NodeWidget<T> class
A widget that builds the visual content of a node.
This widget is responsible for rendering the node's visual appearance:
- Background color and border
- Shape (rectangular, circular, diamond, etc.)
- Content (custom child or default type/id display)
- Selection styling
Important: This widget does NOT handle:
- Positioning (handled by
NodeContainer) - Gestures (handled by
NodeContainer) - Ports (handled by
NodeContainer) - Resize handles (handled by
NodeContainer)
The widget supports three rendering modes:
- Self-rendering: When Node.buildWidget returns non-null, it's used directly (no styling applied - the node controls its own appearance)
- Custom content: Provide a child widget for complete control over node appearance
- Default style: Use NodeWidget.defaultStyle for standard node rendering
Example with custom content:
NodeWidget<MyData>(
node: myNode,
theme: nodeTheme,
child: MyCustomNodeContent(data: myNode.data),
backgroundColor: Colors.blue.shade50,
)
See also:
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- NodeWidget
Constructors
-
NodeWidget({Key? key, required Node<
T> node, required NodeTheme theme, Widget? child, NodeShape? shape, Color? backgroundColor, Color? selectedBackgroundColor, Color? borderColor, Color? selectedBorderColor, double? borderWidth, double? selectedBorderWidth, BorderRadius? borderRadius, EdgeInsets? padding, bool showContent = true}) -
Creates a node widget with optional custom content.
const
-
NodeWidget.defaultStyle({Key? key, required Node<
T> node, required NodeTheme theme, NodeShape? shape, Color? backgroundColor, Color? selectedBackgroundColor, Color? borderColor, Color? selectedBorderColor, double? borderWidth, double? selectedBorderWidth, BorderRadius? borderRadius, EdgeInsets? padding, bool showContent = true}) -
Creates a node widget with default content layout.
const
Properties
- backgroundColor → Color?
-
Custom background color.
final
- borderColor → Color?
-
Custom border color.
final
- borderRadius → BorderRadius?
-
Custom border radius.
final
- borderWidth → double?
-
Custom border width.
final
- child → Widget?
-
Optional custom widget to display as node content.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
node
→ Node<
T> -
The node data model to render.
final
- padding → EdgeInsets?
-
Custom padding inside the node.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selectedBackgroundColor → Color?
-
Custom background color for selected state.
final
- selectedBorderColor → Color?
-
Custom border color for selected state.
final
- selectedBorderWidth → double?
-
Custom border width for selected state.
final
- shape → NodeShape?
-
Optional shape for the node.
final
- showContent → bool
-
Whether to show node content.
final
- theme → NodeTheme
-
The theme for styling the node.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited