copyWith method
ChartTheme
copyWith({
- Color? backgroundColor,
- Color? textColor,
- Color? gridColor,
- Color? axisColor,
- List<
Color> ? gradientColors, - double? shadowElevation,
- double? borderRadius,
- bool? showGrid,
- bool? showAxis,
- bool? showLegend,
- bool? showTooltip,
- Color? cardBorderColor,
- Color? overlayColor,
- Color? crosshairColor,
- Color? tooltipBackgroundColor,
- Color? tooltipBorderColor,
- List<
BoxShadow> ? tooltipShadow, - double? gridLineWidth,
- double? gridDashWidth,
- double? gridDashSpace,
- int? xAxisLabelRotation,
- int? yAxisLabelRotation,
- TextStyle? axisLabelStyle,
- TextStyle? tooltipStyle,
- EdgeInsets? padding,
Creates a copy of this theme with the given fields replaced.
Returns a new ChartTheme with the same values as this one, except for the fields that are explicitly provided. This is useful for creating variations of a theme.
Parameters:
- All parameters are optional. Only provided parameters will override the current theme values.
Example
final customTheme = ChartTheme.light().copyWith(
backgroundColor: Colors.grey[100],
borderRadius: 24.0,
shadowElevation: 8.0,
);
Implementation
ChartTheme copyWith({
Color? backgroundColor,
Color? textColor,
Color? gridColor,
Color? axisColor,
List<Color>? gradientColors,
double? shadowElevation,
double? borderRadius,
bool? showGrid,
bool? showAxis,
bool? showLegend,
bool? showTooltip,
Color? cardBorderColor,
Color? overlayColor,
Color? crosshairColor,
Color? tooltipBackgroundColor,
Color? tooltipBorderColor,
List<BoxShadow>? tooltipShadow,
double? gridLineWidth,
double? gridDashWidth,
double? gridDashSpace,
int? xAxisLabelRotation,
int? yAxisLabelRotation,
TextStyle? axisLabelStyle,
TextStyle? tooltipStyle,
EdgeInsets? padding,
}) {
return ChartTheme(
backgroundColor: backgroundColor ?? this.backgroundColor,
textColor: textColor ?? this.textColor,
gridColor: gridColor ?? this.gridColor,
axisColor: axisColor ?? this.axisColor,
gradientColors: gradientColors ?? this.gradientColors,
shadowElevation: shadowElevation ?? this.shadowElevation,
borderRadius: borderRadius ?? this.borderRadius,
showGrid: showGrid ?? this.showGrid,
showAxis: showAxis ?? this.showAxis,
showLegend: showLegend ?? this.showLegend,
showTooltip: showTooltip ?? this.showTooltip,
cardBorderColor: cardBorderColor ?? this.cardBorderColor,
overlayColor: overlayColor ?? this.overlayColor,
crosshairColor: crosshairColor ?? this.crosshairColor,
tooltipBackgroundColor:
tooltipBackgroundColor ?? this.tooltipBackgroundColor,
tooltipBorderColor: tooltipBorderColor ?? this.tooltipBorderColor,
tooltipShadow: tooltipShadow ?? this.tooltipShadow,
gridLineWidth: gridLineWidth ?? this.gridLineWidth,
gridDashWidth: gridDashWidth ?? this.gridDashWidth,
gridDashSpace: gridDashSpace ?? this.gridDashSpace,
xAxisLabelRotation: xAxisLabelRotation ?? this.xAxisLabelRotation,
yAxisLabelRotation: yAxisLabelRotation ?? this.yAxisLabelRotation,
axisLabelStyle: axisLabelStyle ?? this.axisLabelStyle,
tooltipStyle: tooltipStyle ?? this.tooltipStyle,
padding: padding ?? this.padding,
);
}