copyWith method

ChartTheme copyWith({
  1. Color? backgroundColor,
  2. Color? textColor,
  3. Color? gridColor,
  4. Color? axisColor,
  5. List<Color>? gradientColors,
  6. double? shadowElevation,
  7. double? borderRadius,
  8. bool? showGrid,
  9. bool? showAxis,
  10. bool? showLegend,
  11. bool? showTooltip,
  12. int? xAxisLabelRotation,
  13. int? yAxisLabelRotation,
  14. TextStyle? axisLabelStyle,
  15. TextStyle? tooltipStyle,
  16. 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,
  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,
    xAxisLabelRotation: xAxisLabelRotation ?? this.xAxisLabelRotation,
    yAxisLabelRotation: yAxisLabelRotation ?? this.yAxisLabelRotation,
    axisLabelStyle: axisLabelStyle ?? this.axisLabelStyle,
    tooltipStyle: tooltipStyle ?? this.tooltipStyle,
    padding: padding ?? this.padding,
  );
}