SegmentStyle class

Styling override for a line segment.

When applied to a ChartDataPoint, this style affects the segment from that point to the next point in the series. This enables per-segment color, stroke width, and dash-pattern customization.

Applies to: LineChartSeries, AreaChartSeries

Rendering behavior:

  • Color, strokeWidth, and dashPattern override series defaults for this segment only
  • Null values inherit from series/theme defaults
  • Style on last point is ignored (no segment follows it)
  • Bezier and monotone curves remain smooth at style boundaries

Performance:

  • Fast path: Charts without any segment styles use optimized single-path rendering
  • Batching: Consecutive same-style segments are batched into single draw calls

Example:

// Highlight a single segment in red
ChartDataPoint(
  x: 10.0,
  y: 50.0,
  segmentStyle: SegmentStyle(color: Colors.red, strokeWidth: 3.0),
)

// Using convenience constructor
ChartDataPoint(
  x: 15.0,
  y: 60.0,
  segmentStyle: SegmentStyle.color(Colors.orange),
)

See also:

  • PointStyle for styling individual points in scatter/bar charts
Available extensions
Annotations
  • @chartSurface

Constructors

SegmentStyle({Color? color, double? strokeWidth, List<double>? dashPattern})
Creates a segment style with optional color, width, and pattern overrides.
const
SegmentStyle.color(Color color)
Creates a segment style with only a color override.
const
SegmentStyle.strokeWidth(double strokeWidth)
Creates a segment style with only a stroke width override.
const

Properties

color Color?
Color override for this segment.
final
dashPattern List<double>?
Stroke pattern override for the outgoing segment.
final
hashCode int
The hash code for this object.
no setteroverride
hasOverrides bool
Whether this style has any overrides.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
strokeWidth double?
Stroke width override for this segment.
final

Methods

clearColor() SegmentStyle

Available on SegmentStyle, provided by the SegmentStyleFluent extension

Clears SegmentStyle.color to null.
clearDashPattern() SegmentStyle

Available on SegmentStyle, provided by the SegmentStyleFluent extension

Clears SegmentStyle.dashPattern to null.
clearStrokeWidth() SegmentStyle

Available on SegmentStyle, provided by the SegmentStyleFluent extension

Clears SegmentStyle.strokeWidth to null.
copyWith({Color? color, double? strokeWidth, List<double>? dashPattern, bool clearColor = false, bool clearStrokeWidth = false, bool clearDashPattern = false}) SegmentStyle
Creates a copy of this style with the given overrides.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override
withColor(Color value) SegmentStyle

Available on SegmentStyle, provided by the SegmentStyleFluent extension

Replaces SegmentStyle.color with value.
withDashPattern(List<double> value) SegmentStyle

Available on SegmentStyle, provided by the SegmentStyleFluent extension

Replaces SegmentStyle.dashPattern with value.
withStrokeWidth(double value) SegmentStyle

Available on SegmentStyle, provided by the SegmentStyleFluent extension

Replaces SegmentStyle.strokeWidth with value.

Operators

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