Skip to content

feat!: Add support for unified customization of path pattern#2106

Open
nikodembernat wants to merge 6 commits into
imaNNeo:mainfrom
nikodembernat-nubank:path-dash-data
Open

feat!: Add support for unified customization of path pattern#2106
nikodembernat wants to merge 6 commits into
imaNNeo:mainfrom
nikodembernat-nubank:path-dash-data

Conversation

@nikodembernat

@nikodembernat nikodembernat commented May 26, 2026

Copy link
Copy Markdown

Description

This PR adds a unified way of customizing various lines (bar chart border, line chart dashes, etc.).

Checklist

  • I have followed the [Contributor Guide] when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation and added dartdoc comments with ///.
  • I have updated/added relevant examples in example.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Migration instructions

I tried balancing required changes and backwards-compatibility, so all existing fields in the constructors should continue to work, but are marked as deprecated. It results in some more complex logic inside FlLine since it's the only one that uses a const constructor, but I added an assertion to make sure people don't make partial migrations.

As for examples of migration, it's quite straightforward:

// Also applies to `HorizontalLine` and `VerticalLine`.
FlLine(
-  dashArray: [4, 4],
+  pathData: const FlPathData(dashArray: [4, 4]),
)
BarChartRodData(
-  borderDashArray: [4, 4],
+  pathData: const FlPathData(dashArray: [4, 4]),
),
LineChartBarData(
-  isStrokeCapRound: true,
-  dashArray: [4, 4],
+  pathData: const FlPathData(
+    dashArray: [4, 4],
+    strokeCap: StrokeCap.round,
+  ),
),

tldr: everything uses the following class

// FlPathData
final StrokeCap strokeCap;
final StrokeJoin strokeJoin;
final double strokeMiterLimit;
final List<int>? dashArray;

Additional notes

  • Besides tests for new functionality, I added some additional test cases to test backwards-compatibility.
  • It was initially called FlDashData, but then I realized that it's not always used in the context of dashes (e.g. LineChartBarData -> strokeCap), so I renamed it to FlPathData.
  • It shows hundreds of changed lines in tests, but it's only formatting - I added a wrapper to test the same behavior for legacy and new dash pattern (start by looking into data_pool.dart, it should clarify some stuff).
  • I'm open to changes.

@nikodembernat nikodembernat marked this pull request as ready for review May 26, 2026 20:32
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