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. Color? cardBorderColor,
  13. Color? overlayColor,
  14. Color? crosshairColor,
  15. Color? tooltipBackgroundColor,
  16. Color? tooltipBorderColor,
  17. List<BoxShadow>? tooltipShadow,
  18. double? gridLineWidth,
  19. double? gridDashWidth,
  20. double? gridDashSpace,
  21. int? xAxisLabelRotation,
  22. int? yAxisLabelRotation,
  23. TextStyle? axisLabelStyle,
  24. TextStyle? tooltipStyle,
  25. 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,
  );
}