LegendStyle class

Immutable legend style configuration.

Defines the visual styling for chart legends including position, colors, borders, fonts, and layout options.

Example:

LegendStyle(
  position: LegendPosition.topRight,
  backgroundColor: Colors.white.withOpacity(0.9),
  borderColor: Colors.grey,
  textStyle: TextStyle(fontSize: 11, color: Colors.black87),
  markerShape: LegendMarkerShape.line,
  padding: EdgeInsets.all(8),
)
Available extensions
Annotations

Constructors

LegendStyle({LegendPosition position = LegendPosition.topRight, LegendOrientation orientation = LegendOrientation.horizontal, TextStyle textStyle = const TextStyle(fontSize: 11.0, fontWeight: FontWeight.normal, color: Colors.black87), Color? backgroundColor, Color? borderColor, double borderWidth = 0.0, BorderRadius? borderRadius, EdgeInsets? padding, double itemSpacing = 6.0, double markerSize = 16.0, LegendMarkerShape markerShape = LegendMarkerShape.line, double markerLineWidth = 4.0, double markerLabelSpacing = 6.0, bool allowDragging = true, double opacity = 1.0, Offset offset = Offset.zero})
Creates a legend style.
const

Properties

allowDragging → bool
Whether the legend can be dragged to reposition.
final
backgroundColor → Color?
Background color for the legend container (optional).
final
borderColor → Color?
Border color for the legend outline (optional).
final
borderRadius → BorderRadius?
Border radius for rounded corners.
final
borderWidth → double
Border width in logical pixels.
final
effectiveBackgroundColor → Color
Effective background color with default fallback. Default is semi-transparent white (~30% opacity) - no border by default.
no setter
effectiveBorderColor → Color
Effective border color with default fallback.
no setter
effectiveBorderRadius → BorderRadius
Effective border radius with default fallback.
no setter
effectivePadding → EdgeInsets
Effective padding with default fallback.
no setter
hashCode → int
The hash code for this object.
no setteroverride
itemSpacing → double
Spacing between legend items.
final
markerLabelSpacing → double
Spacing between marker and label text.
final
markerLineWidth → double
Width of the line marker (when markerShape is line).
final
markerShape → LegendMarkerShape
Shape of the color marker/indicator.
final
markerSize → double
Size of the color marker/indicator.
final
offset → Offset
Offset from the anchored position.
final
opacity → double
Overall opacity of the legend.
final
orientation → LegendOrientation
Layout orientation for legend items.
final
padding → EdgeInsets?
Padding inside the legend container.
final
position → LegendPosition
Position where the legend is anchored.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
textStyle → TextStyle
Text style for legend item labels.
final

Methods

clearBackgroundColor() → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Clears LegendStyle.backgroundColor to null.
clearBorderColor() → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Clears LegendStyle.borderColor to null.
clearBorderRadius() → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Clears LegendStyle.borderRadius to null.
clearPadding() → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Clears LegendStyle.padding to null.
copyWith({LegendPosition? position, LegendOrientation? orientation, TextStyle? textStyle, Color? backgroundColor, Color? borderColor, double? borderWidth, BorderRadius? borderRadius, EdgeInsets? padding, double? itemSpacing, double? markerSize, LegendMarkerShape? markerShape, double? markerLineWidth, double? markerLabelSpacing, bool? allowDragging, double? opacity, Offset? offset, bool clearBackgroundColor = false, bool clearBorderColor = false, bool clearBorderRadius = false, bool clearPadding = false}) → LegendStyle
Creates a copy with modified properties.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
withAllowDragging(bool value) → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Replaces LegendStyle.allowDragging with value.
withBackgroundColor(Color value) → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Replaces LegendStyle.backgroundColor with value.
withBorderColor(Color value) → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Replaces LegendStyle.borderColor with value.
withBorderRadius(BorderRadius value) → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Replaces LegendStyle.borderRadius with value.
withBorderWidth(double value) → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Replaces LegendStyle.borderWidth with value.
withItemSpacing(double value) → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Replaces LegendStyle.itemSpacing with value.
withMarkerLabelSpacing(double value) → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Replaces LegendStyle.markerLabelSpacing with value.
withMarkerLineWidth(double value) → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Replaces LegendStyle.markerLineWidth with value.
withMarkerShape(LegendMarkerShape value) → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Replaces LegendStyle.markerShape with value.
withMarkerSize(double value) → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Replaces LegendStyle.markerSize with value.
withOffset(Offset value) → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Replaces LegendStyle.offset with value.
withOpacity(double value) → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Replaces LegendStyle.opacity with value.
withOrientation(LegendOrientation value) → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Replaces LegendStyle.orientation with value.
withPadding(EdgeInsets value) → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Replaces LegendStyle.padding with value.
withPosition(LegendPosition value) → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Replaces LegendStyle.position with value.
withTextStyle(TextStyle value) → LegendStyle

Available on LegendStyle, provided by the LegendStyleFluent extension

Replaces LegendStyle.textStyle with value.

Operators

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

Constants

dark → const LegendStyle
Default dark theme legend style.
light → const LegendStyle
Default light theme legend style.