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
-
- @immutable
- @chartSurface
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 tonull. -
clearBorderColor(
) → LegendStyle -
Available on LegendStyle, provided by the LegendStyleFluent extension
Clears LegendStyle.borderColor tonull. -
clearBorderRadius(
) → LegendStyle -
Available on LegendStyle, provided by the LegendStyleFluent extension
Clears LegendStyle.borderRadius tonull. -
clearPadding(
) → LegendStyle -
Available on LegendStyle, provided by the LegendStyleFluent extension
Clears LegendStyle.padding tonull. -
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 withvalue. -
withBackgroundColor(
Color value) → LegendStyle -
Available on LegendStyle, provided by the LegendStyleFluent extension
Replaces LegendStyle.backgroundColor withvalue. -
withBorderColor(
Color value) → LegendStyle -
Available on LegendStyle, provided by the LegendStyleFluent extension
Replaces LegendStyle.borderColor withvalue. -
withBorderRadius(
BorderRadius value) → LegendStyle -
Available on LegendStyle, provided by the LegendStyleFluent extension
Replaces LegendStyle.borderRadius withvalue. -
withBorderWidth(
double value) → LegendStyle -
Available on LegendStyle, provided by the LegendStyleFluent extension
Replaces LegendStyle.borderWidth withvalue. -
withItemSpacing(
double value) → LegendStyle -
Available on LegendStyle, provided by the LegendStyleFluent extension
Replaces LegendStyle.itemSpacing withvalue. -
withMarkerLabelSpacing(
double value) → LegendStyle -
Available on LegendStyle, provided by the LegendStyleFluent extension
Replaces LegendStyle.markerLabelSpacing withvalue. -
withMarkerLineWidth(
double value) → LegendStyle -
Available on LegendStyle, provided by the LegendStyleFluent extension
Replaces LegendStyle.markerLineWidth withvalue. -
withMarkerShape(
LegendMarkerShape value) → LegendStyle -
Available on LegendStyle, provided by the LegendStyleFluent extension
Replaces LegendStyle.markerShape withvalue. -
withMarkerSize(
double value) → LegendStyle -
Available on LegendStyle, provided by the LegendStyleFluent extension
Replaces LegendStyle.markerSize withvalue. -
withOffset(
Offset value) → LegendStyle -
Available on LegendStyle, provided by the LegendStyleFluent extension
Replaces LegendStyle.offset withvalue. -
withOpacity(
double value) → LegendStyle -
Available on LegendStyle, provided by the LegendStyleFluent extension
Replaces LegendStyle.opacity withvalue. -
withOrientation(
LegendOrientation value) → LegendStyle -
Available on LegendStyle, provided by the LegendStyleFluent extension
Replaces LegendStyle.orientation withvalue. -
withPadding(
EdgeInsets value) → LegendStyle -
Available on LegendStyle, provided by the LegendStyleFluent extension
Replaces LegendStyle.padding withvalue. -
withPosition(
LegendPosition value) → LegendStyle -
Available on LegendStyle, provided by the LegendStyleFluent extension
Replaces LegendStyle.position withvalue. -
withTextStyle(
TextStyle value) → LegendStyle -
Available on LegendStyle, provided by the LegendStyleFluent extension
Replaces LegendStyle.textStyle withvalue.
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.