Theme API

API reference for theming classes

Theme API

Complete reference for all theming classes in Vyuh Node Flow.

NodeFlowTheme

The top-level theme configuration. Extends Flutter's ThemeExtension for integration with the theming system.

NodeFlowTheme({
  required NodeTheme nodeTheme,
  required ConnectionTheme connectionTheme,
  required ConnectionTheme temporaryConnectionTheme,
  Duration connectionAnimationDuration = const Duration(seconds: 2),
  required PortTheme portTheme,
  required LabelTheme labelTheme,
  required AnnotationTheme annotationTheme,
  required GridTheme gridTheme,
  required SelectionTheme selectionTheme,
  required CursorTheme cursorTheme,
  Color backgroundColor = Colors.white,
  bool debugMode = false,
  DebugTheme debugTheme = DebugTheme.light,
})

Most theme properties are required. Use NodeFlowTheme.light or NodeFlowTheme.dark as starting points.

Properties

PropertyTypeRequiredDescription
nodeThemeNodeThemeYesNode appearance
connectionThemeConnectionThemeYesEstablished connection appearance
temporaryConnectionThemeConnectionThemeYesConnection during creation
connectionAnimationDurationDurationNoAnimation cycle duration
portThemePortThemeYesPort appearance
labelThemeLabelThemeYesConnection label styling
annotationThemeAnnotationThemeYesAnnotation appearance
gridThemeGridThemeYesGrid background
selectionThemeSelectionThemeYesSelection rectangle styling
cursorThemeCursorThemeYesMouse cursor styles
backgroundColorColorNoCanvas background
debugModeboolNoEnable debug overlays
debugThemeDebugThemeNoDebug visualization styling

Preset Themes

// Light theme
NodeFlowTheme.light

// Dark theme
NodeFlowTheme.dark

copyWith

final customTheme = NodeFlowTheme.light.copyWith(
  backgroundColor: Colors.grey[50],
  nodeTheme: NodeTheme.light.copyWith(
    backgroundColor: Colors.blue[50],
  ),
);

NodeTheme

Style configuration for nodes.

NodeTheme({
  required Color backgroundColor,
  required Color selectedBackgroundColor,
  required Color borderColor,
  required Color selectedBorderColor,
  required double borderWidth,
  required double selectedBorderWidth,
  required BorderRadius borderRadius,
  required List<BoxShadow> shadow,
  required List<BoxShadow> selectedShadow,
})
PropertyTypeDescription
backgroundColorColorDefault background
selectedBackgroundColorColorBackground when selected
borderColorColorDefault border color
selectedBorderColorColorBorder when selected
borderWidthdoubleDefault border width
selectedBorderWidthdoubleBorder width when selected
borderRadiusBorderRadiusCorner rounding
shadowList<BoxShadow>Default shadow
selectedShadowList<BoxShadow>Shadow when selected

Preset themes:

NodeTheme.light
NodeTheme.dark

Example:

NodeTheme(
  backgroundColor: Colors.white,
  selectedBackgroundColor: Colors.blue[50]!,
  borderColor: Colors.grey[300]!,
  selectedBorderColor: Colors.blue,
  borderWidth: 1,
  selectedBorderWidth: 2,
  borderRadius: BorderRadius.circular(8),
  shadow: [
    BoxShadow(
      color: Colors.black12,
      blurRadius: 4,
      offset: Offset(0, 2),
    ),
  ],
  selectedShadow: [
    BoxShadow(
      color: Colors.blue.withOpacity(0.3),
      blurRadius: 8,
      offset: Offset(0, 2),
    ),
  ],
)

ConnectionTheme

Style configuration for connections.

ConnectionTheme({
  required ConnectionStyle style,
  required Color color,
  required Color selectedColor,
  required double strokeWidth,
  required double selectedStrokeWidth,
  List<double>? dashPattern,
  required ConnectionEndPoint startPoint,
  required ConnectionEndPoint endPoint,
  required Color endpointColor,
  required Color endpointBorderColor,
  required double endpointBorderWidth,
  ConnectionEffect? animationEffect,
  required double bezierCurvature,
  required double cornerRadius,
  required double portExtension,
  required double backEdgeGap,
  required double hitTolerance,
  double startGap = 0.0,
  double endGap = 0.0,
})
PropertyTypeDescription
styleConnectionStyleLine style (bezier, smoothstep, etc.)
colorColorDefault line color
selectedColorColorColor when selected
strokeWidthdoubleDefault line width
selectedStrokeWidthdoubleWidth when selected
dashPatternList<double>?Dash pattern [dash, gap]
startPointConnectionEndPointStart marker
endPointConnectionEndPointEnd marker
endpointColorColorMarker fill color
endpointBorderColorColorMarker border color
endpointBorderWidthdoubleMarker border width
animationEffectConnectionEffect?Default animation effect
bezierCurvaturedoubleBezier curve factor (0-1)
cornerRadiusdoubleStep connection corner radius
portExtensiondoubleStraight distance from port
backEdgeGapdoubleGap for loopback routing
hitTolerancedoubleClick/tap hit area tolerance
startGapdoubleGap from source port
endGapdoubleGap from target port

Preset themes:

ConnectionTheme.light
ConnectionTheme.dark

ConnectionEndPoint

Markers at connection endpoints.

ConnectionEndPoint({
  required MarkerShape shape,
  Size? size,
  Color? color,
  Color? borderColor,
  double? borderWidth,
})

// Built-in constants
ConnectionEndPoint.none       // No marker
ConnectionEndPoint.capsuleHalf // Capsule half shape (default for end)
ConnectionEndPoint.triangle   // Arrow/triangle

Endpoint shapes use MarkerShape, not a separate EndpointShape enum.

ConnectionStyle

Path rendering styles via ConnectionStyles:

StyleDescription
ConnectionStyles.straightDirect line
ConnectionStyles.bezierCurved Bezier
ConnectionStyles.stepRight-angle segments
ConnectionStyles.smoothstepSmooth orthogonal (default)

PortTheme

Style configuration for ports.

PortTheme({
  required Size size,
  required Color color,
  required Color connectedColor,
  required Color snappingColor,
  required Color borderColor,
  required double borderWidth,
  MarkerShape shape = MarkerShapes.capsuleHalf,
  bool showLabel = false,
  TextStyle? labelTextStyle,
  double labelOffset = 4.0,
  double labelVisibilityThreshold = 0.5,
  Color highlightBorderColor = const Color(0xFF000000),
  double highlightBorderWidthDelta = 1.5,
})
PropertyTypeDescription
sizeSizePort dimensions (width, height)
colorColorDefault fill color
connectedColorColorColor when connected
snappingColorColorColor during connection drag
borderColorColorBorder color
borderWidthdoubleBorder thickness
shapeMarkerShapeDefault marker shape
showLabelboolGlobal label visibility
labelTextStyleTextStyle?Label text style
labelOffsetdoublePort to label distance
labelVisibilityThresholddoubleMin zoom to show labels
highlightBorderColorColorBorder color when highlighted
highlightBorderWidthDeltadoubleExtra border width when highlighted

Preset themes:

PortTheme.light
PortTheme.dark

Port size is a Size object (width x height), not a single double value.

GridTheme

Style configuration for the background grid.

GridTheme({
  required GridStyle style,
  required Color color,
  required double size,
  required double thickness,
})
PropertyTypeDescription
styleGridStyleGrid pattern style
colorColorGrid line/dot color
sizedoubleGrid cell size
thicknessdoubleLine thickness

GridStyle

StyleDescription
GridStyles.noneNo grid
GridStyles.dotsDot pattern
GridStyles.linesLine grid
GridStyles.crossCross pattern
GridStyles.hierarchicalHierarchical grid with major/minor lines

Preset themes:

GridTheme.light
GridTheme.dark

Example:

GridTheme(
  style: GridStyles.dots,
  color: Colors.grey[300]!,
  size: 20,
  thickness: 1,
)

LabelTheme

Style configuration for connection labels.

LabelTheme({
  required TextStyle textStyle,
  required Color backgroundColor,
  required EdgeInsets padding,
  required BorderRadius borderRadius,
  Border? border,
})

Preset themes:

LabelTheme.light
LabelTheme.dark

Example:

LabelTheme(
  textStyle: TextStyle(fontSize: 12, color: Colors.black87),
  backgroundColor: Colors.white,
  padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
  borderRadius: BorderRadius.circular(4),
  border: Border.all(color: Colors.grey[300]!),
)

SelectionTheme

Style configuration for selection rectangle.

SelectionTheme({
  required Color fillColor,
  required Color borderColor,
  required double borderWidth,
})

Preset themes:

SelectionTheme.light
SelectionTheme.dark

AnnotationTheme

Style configuration for annotations (sticky notes, groups).

AnnotationTheme({
  required Color selectionColor,
  required double selectionBorderWidth,
  // Additional properties for sticky notes, groups, markers
})

Preset themes:

AnnotationTheme.light
AnnotationTheme.dark

CursorTheme

Mouse cursor styles for different interactions.

CursorTheme({
  required MouseCursor defaultCursor,
  required MouseCursor grabbingCursor,
  required MouseCursor moveCursor,
  required MouseCursor resizeCursor,
  // Additional cursor configurations
})

Preset themes:

CursorTheme.light
CursorTheme.dark

DebugTheme

Theme for debug visualization overlays.

DebugTheme({
  required Color gridColor,
  required Color cellColor,
  required Color textColor,
  // Additional debug styling properties
})

Preset themes:

DebugTheme.light
DebugTheme.dark

Complete Example

NodeFlowEditor(
  controller: controller,
  theme: NodeFlowTheme.light,
  nodeBuilder: (context, node) => Text(node.data.label),
)
NodeFlowEditor(
  controller: controller,
  theme: NodeFlowTheme.dark,
  nodeBuilder: (context, node) => Text(node.data.label),
)
NodeFlowEditor(
  controller: controller,
  theme: NodeFlowTheme.light.copyWith(
    backgroundColor: Color(0xFFF5F5F5),
    nodeTheme: NodeTheme.light.copyWith(
      backgroundColor: Colors.white,
      selectedBorderColor: Colors.indigo,
      borderRadius: BorderRadius.circular(12),
    ),
    connectionTheme: ConnectionTheme.light.copyWith(
      color: Colors.grey[600],
      selectedColor: Colors.indigo,
      strokeWidth: 2.0,
      endPoint: ConnectionEndPoint.triangle,
    ),
    portTheme: PortTheme.light.copyWith(
      size: Size(12, 12),
      color: Colors.grey[400],
      connectedColor: Colors.indigo,
    ),
    gridTheme: GridTheme.light.copyWith(
      style: GridStyles.hierarchical,
      color: Colors.grey[200],
      size: 20,
    ),
  ),
  nodeBuilder: (context, node) => Text(node.data.label),
)

Theme Integration

Access theme from Flutter's theme system:

// In your Theme widget
Theme(
  data: ThemeData.light().copyWith(
    extensions: [NodeFlowTheme.light],
  ),
  child: MyApp(),
)

// Access in widgets
final flowTheme = Theme.of(context).extension<NodeFlowTheme>()!;

See Also

On this page