Skip to content

fix: Fix missing and incorrect copyWith parameters across chart tooltip data classes#2094

Open
WandsonDev wants to merge 1 commit into
imaNNeo:mainfrom
WandsonDev:fix/copywith-missing-fields
Open

fix: Fix missing and incorrect copyWith parameters across chart tooltip data classes#2094
WandsonDev wants to merge 1 commit into
imaNNeo:mainfrom
WandsonDev:fix/copywith-missing-fields

Conversation

@WandsonDev
Copy link
Copy Markdown

Description

Several copyWith methods across chart data classes were incomplete or had bugs that silently ignored caller-supplied values, making it impossible to update chart configuration through copyWith.

Changes

BarChartRodData.copyWith — The parameter was named dashArray instead of borderDashArray, causing the constructor call to resolve to this.borderDashArray (the instance field) instead of the caller-supplied value. Renamed to borderDashArray and added the missing ?? this.borderDashArray fallback.

BarTouchTooltipData — Added missing copyWith method. Also added the direction field to props, which was missing from the equality check — two objects with different direction values were incorrectly considered equal.

LineTouchTooltipData — Added missing copyWith method.

CandlestickTouchTooltipData.copyWith — Added missing showOnTopOfTheChartBoxArea parameter.

ScatterTouchTooltipData.copyWith — Added missing tooltipBorderRadius parameter.

ScatterChartData.props — Removed duplicate rangeAnnotations entry.

Tests

Regression tests added for each fix to prevent regressions.

Checklist

  • make sure passes (tests + checkstyle)
  • Regression tests added
  • No breaking changes (all additions are additive; parameter rename in BarChartRodData.copyWith aligns with the existing field name — the old dashArray name was never usable due to the bug)

…ip data classes

Several copyWith methods were incomplete or had bugs that silently
ignored caller-supplied values, making it impossible to update chart
configuration through copyWith.

- BarChartRodData: rename parameter `dashArray` → `borderDashArray` and
  add the missing `?? this.borderDashArray` fallback so the parameter is
  actually forwarded instead of silently discarded
- BarTouchTooltipData: add missing copyWith method; also add `direction`
  field to props so equality checks reflect direction changes
- LineTouchTooltipData: add missing copyWith method
- CandlestickTouchTooltipData.copyWith: add missing
  `showOnTopOfTheChartBoxArea` parameter
- ScatterTouchTooltipData.copyWith: add missing `tooltipBorderRadius`
  parameter
- ScatterChartData.props: remove duplicate `rangeAnnotations` entry

Regression tests added for each fix.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.07%. Comparing base (15562ee) to head (7a9d236).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2094   +/-   ##
=======================================
  Coverage   93.07%   93.07%           
=======================================
  Files          50       50           
  Lines        3956     3956           
=======================================
  Hits         3682     3682           
  Misses        274      274           
Flag Coverage Δ
flutter 93.07% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Gradient? gradient,
double? width,
BorderRadius? borderRadius,
List<int>? dashArray,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing that worries me is this property that we're removing (it adds a breaking change)
But the point is that the value here was ignored. So I don't know what to do, haha.

Maybe we can go ahead with the breaking change as it is a special edge-case

Copy link
Copy Markdown
Owner

@imaNNeo imaNNeo Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a professional way, we should deprecate the previous name and introduce the new name. But in this case it doesn't really make sense.

@imaNNeo
Copy link
Copy Markdown
Owner

imaNNeo commented Apr 28, 2026

Please let me know what you think, other than that, it looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants