Skip to content

Commit 2e8686a

Browse files
committed
Deprecate swapAnimationDuration and swapAnimationCurve properties to use curve and duration instead to keep the consistency over the project, #1618
1 parent c44d396 commit 2e8686a

File tree

9 files changed

+48
-35
lines changed

9 files changed

+48
-35
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## newVersion
2+
* **IMPROVEMENT** (by @moshe5745) Update the docs related to line chart's `duration` and `curve` properties, #1618
3+
* **IMPROVEMENT** (by @imaNNeo) Deprecate `swapAnimationDuration` and `swapAnimationCurve` properties to use `curve` and `duration` instead to keep the consistency over the project, #1618
4+
15
## 0.69.0
26
* **BUGFIX** (by @imaNNeo) Fix a memory leak issue in the axis-based charts, there was a logic to calculate and cache the minX, maxX, minY and maxY properties to reduce the computation cost. But it caused some memory issues, as we don't have a quick solution for this, we disabled the caching logic for now, later we can move the calculation logic to the render objects to keep and update them only when the data is changed, #1106, #1693
37
* **BUGFIX** (by @imaNNeo) Fix showing grid lines even when there is no line to show in the LineChart, #1691

lib/src/chart/bar_chart/bar_chart.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@ import 'package:flutter/cupertino.dart';
88
class BarChart extends ImplicitlyAnimatedWidget {
99
/// [data] determines how the [BarChart] should be look like,
1010
/// when you make any change in the [BarChartData], it updates
11-
/// new values with animation, and duration is [swapAnimationDuration].
12-
/// also you can change the [swapAnimationCurve]
11+
/// new values with animation, and duration is [duration].
12+
/// also you can change the [curve]
1313
/// which default is [Curves.linear].
1414
const BarChart(
1515
this.data, {
1616
this.chartRendererKey,
1717
super.key,
18-
Duration swapAnimationDuration = const Duration(milliseconds: 150),
19-
Curve swapAnimationCurve = Curves.linear,
18+
@Deprecated('Please use duration instead') Duration? swapAnimationDuration,
19+
Duration duration = const Duration(milliseconds: 150),
20+
@Deprecated('Please use curve instead') Curve? swapAnimationCurve,
21+
Curve curve = Curves.linear,
2022
}) : super(
21-
duration: swapAnimationDuration,
22-
curve: swapAnimationCurve,
23+
duration: swapAnimationDuration ?? duration,
24+
curve: swapAnimationCurve ?? curve,
2325
);
2426

2527
/// Determines how the [BarChart] should be look like.

lib/src/chart/line_chart/line_chart.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import 'package:flutter/material.dart';
99
class LineChart extends ImplicitlyAnimatedWidget {
1010
/// [data] determines how the [LineChart] should be look like,
1111
/// when you make any change in the [LineChartData], it updates
12-
/// new values with animation, and duration is [swapAnimationDuration].
13-
/// also you can change the [swapAnimationCurve]
12+
/// new values with animation, and duration is [duration].
13+
/// also you can change the [curve]
1414
/// which default is [Curves.linear].
1515
const LineChart(
1616
this.data, {

lib/src/chart/pie_chart/pie_chart.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@ import 'package:flutter/material.dart';
66
class PieChart extends ImplicitlyAnimatedWidget {
77
/// [data] determines how the [PieChart] should be look like,
88
/// when you make any change in the [PieChartData], it updates
9-
/// new values with animation, and duration is [swapAnimationDuration].
10-
/// also you can change the [swapAnimationCurve]
9+
/// new values with animation, and duration is [duration].
10+
/// also you can change the [curve]
1111
/// which default is [Curves.linear].
1212
const PieChart(
1313
this.data, {
1414
super.key,
15-
Duration swapAnimationDuration = defaultDuration,
16-
Curve swapAnimationCurve = Curves.linear,
15+
@Deprecated('Please use duration instead') Duration? swapAnimationDuration,
16+
Duration duration = const Duration(milliseconds: 150),
17+
@Deprecated('Please use curve instead') Curve? swapAnimationCurve,
18+
Curve curve = Curves.linear,
1719
}) : super(
18-
duration: swapAnimationDuration,
19-
curve: swapAnimationCurve,
20+
duration: swapAnimationDuration ?? duration,
21+
curve: swapAnimationCurve ?? curve,
2022
);
2123

2224
/// Default duration to reuse externally.
@@ -86,6 +88,7 @@ class BadgeWidgetsDelegate extends MultiChildLayoutDelegate {
8688
required this.badgeWidgetsCount,
8789
required this.badgeWidgetsOffsets,
8890
});
91+
8992
final int badgeWidgetsCount;
9093
final Map<int, Offset> badgeWidgetsOffsets;
9194

lib/src/chart/radar_chart/radar_chart.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@ import 'package:flutter/material.dart';
66
class RadarChart extends ImplicitlyAnimatedWidget {
77
/// [data] determines how the [RadarChart] should be look like,
88
/// when you make any change in the [RadarChart], it updates
9-
/// new values with animation, and duration is [swapAnimationDuration].
10-
/// also you can change the [swapAnimationCurve]
9+
/// new values with animation, and duration is [duration].
10+
/// also you can change the [curve]
1111
/// which default is [Curves.linear].
1212
const RadarChart(
1313
this.data, {
1414
super.key,
15-
Duration swapAnimationDuration = const Duration(milliseconds: 150),
16-
Curve swapAnimationCurve = Curves.linear,
15+
@Deprecated('Please use duration instead') Duration? swapAnimationDuration,
16+
Duration duration = const Duration(milliseconds: 150),
17+
@Deprecated('Please use curve instead') Curve? swapAnimationCurve,
18+
Curve curve = Curves.linear,
1719
}) : super(
18-
duration: swapAnimationDuration,
19-
curve: swapAnimationCurve,
20+
duration: swapAnimationDuration ?? duration,
21+
curve: swapAnimationCurve ?? curve,
2022
);
2123

2224
/// Determines how the [RadarChart] should be look like.

lib/src/chart/scatter_chart/scatter_chart.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ import 'package:flutter/cupertino.dart';
77
class ScatterChart extends ImplicitlyAnimatedWidget {
88
/// [data] determines how the [ScatterChart] should be look like,
99
/// when you make any change in the [ScatterChartData], it updates
10-
/// new values with animation, and duration is [swapAnimationDuration].
11-
/// also you can change the [swapAnimationCurve]
10+
/// new values with animation, and duration is [duration].
11+
/// also you can change the [curve]
1212
/// which default is [Curves.linear].
1313
const ScatterChart(
1414
this.data, {
1515
this.chartRendererKey,
1616
super.key,
17-
Duration swapAnimationDuration = const Duration(milliseconds: 150),
18-
Curve swapAnimationCurve = Curves.linear,
17+
@Deprecated('Please use duration instead') Duration? swapAnimationDuration,
18+
Duration duration = const Duration(milliseconds: 150),
19+
@Deprecated('Please use curve instead') Curve? swapAnimationCurve,
20+
Curve curve = Curves.linear,
1921
}) : super(
20-
duration: swapAnimationDuration,
21-
curve: swapAnimationCurve,
22+
duration: swapAnimationDuration ?? duration,
23+
curve: swapAnimationCurve ?? curve,
2224
);
2325

2426
/// Determines how the [ScatterChart] should be look like.

repo_files/documentations/bar_chart.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ BarChart(
66
BarChartData(
77
// read about it in the BarChartData section
88
),
9-
swapAnimationDuration: Duration(milliseconds: 150), // Optional
10-
swapAnimationCurve: Curves.linear, // Optional
9+
duration: Duration(milliseconds: 150), // Optional
10+
curve: Curves.linear, // Optional
1111
);
1212
```
1313

1414
### Implicit Animations
15-
When you change the chart's state, it animates to the new state internally (using [implicit animations](https://flutter.dev/docs/development/ui/animations/implicit-animations)). You can control the animation [duration](https://api.flutter.dev/flutter/dart-core/Duration-class.html) and [curve](https://api.flutter.dev/flutter/animation/Curves-class.html) using optional `swapAnimationDuration` and `swapAnimationCurve` properties, respectively.
15+
When you change the chart's state, it animates to the new state internally (using [implicit animations](https://flutter.dev/docs/development/ui/animations/implicit-animations)). You can control the animation [duration](https://api.flutter.dev/flutter/dart-core/Duration-class.html) and [curve](https://api.flutter.dev/flutter/animation/Curves-class.html) using optional `duration` and `curve` properties, respectively.
1616

1717
### BarChartData
1818
|PropName |Description |default value|

repo_files/documentations/pie_chart.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ PieChart(
66
PieChartData(
77
// read about it in the PieChartData section
88
),
9-
swapAnimationDuration: Duration(milliseconds: 150), // Optional
10-
swapAnimationCurve: Curves.linear, // Optional
9+
duration: Duration(milliseconds: 150), // Optional
10+
curve: Curves.linear, // Optional
1111
);
1212
```
1313

1414
**If you have a padding widget around the PieChart, make sure to set `PieChartData.centerSpaceRadius` to `double.infinity`**
1515

1616

1717
### Implicit Animations
18-
When you change the chart's state, it animates to the new state internally (using [implicit animations](https://flutter.dev/docs/development/ui/animations/implicit-animations)). You can control the animation [duration](https://api.flutter.dev/flutter/dart-core/Duration-class.html) and [curve](https://api.flutter.dev/flutter/animation/Curves-class.html) using optional `swapAnimationDuration` and `swapAnimationCurve` properties, respectively.
18+
When you change the chart's state, it animates to the new state internally (using [implicit animations](https://flutter.dev/docs/development/ui/animations/implicit-animations)). You can control the animation [duration](https://api.flutter.dev/flutter/dart-core/Duration-class.html) and [curve](https://api.flutter.dev/flutter/animation/Curves-class.html) using optional `duration` and `curve` properties, respectively.
1919

2020
### PieChartData
2121
|PropName |Description |default value|

repo_files/documentations/scatter_chart.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ ScatterChart(
88
ScatterChartData(
99
// read about it in the ScatterChartData section
1010
),
11-
swapAnimationDuration: Duration(milliseconds: 150), // Optional
12-
swapAnimationCurve: Curves.linear, // Optional
11+
duration: Duration(milliseconds: 150), // Optional
12+
curve: Curves.linear, // Optional
1313
);
1414
```
1515

1616
### Implicit Animations
17-
When you change the chart's state, it animates to the new state internally (using [implicit animations](https://flutter.dev/docs/development/ui/animations/implicit-animations)). You can control the animation [duration](https://api.flutter.dev/flutter/dart-core/Duration-class.html) and [curve](https://api.flutter.dev/flutter/animation/Curves-class.html) using optional `swapAnimationDuration` and `swapAnimationCurve` properties, respectively.
17+
When you change the chart's state, it animates to the new state internally (using [implicit animations](https://flutter.dev/docs/development/ui/animations/implicit-animations)). You can control the animation [duration](https://api.flutter.dev/flutter/dart-core/Duration-class.html) and [curve](https://api.flutter.dev/flutter/animation/Curves-class.html) using optional `duration` and `curve` properties, respectively.
1818

1919
### ScatterChartData
2020
|PropName |Description |default value|

0 commit comments

Comments
 (0)