Skip to content

Commit

Permalink
Deprecate swapAnimationDuration and swapAnimationCurve properties…
Browse files Browse the repository at this point in the history
… to use `curve` and `duration` instead to keep the consistency over the project, #1618
  • Loading branch information
imaNNeo committed Nov 20, 2024
1 parent c44d396 commit ef1c016
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 35 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.69.1
* **IMPROVEMENT** (by @moshe5745) Update the docs related to line chart's `duration` and `curve` properties, #1618
* **IMPROVEMENT** (by @imaNNeo) Deprecate `swapAnimationDuration` and `swapAnimationCurve` properties to use `curve` and `duration` instead to keep the consistency over the project, #1618

## 0.69.0
* **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
* **BUGFIX** (by @imaNNeo) Fix showing grid lines even when there is no line to show in the LineChart, #1691
Expand Down
14 changes: 8 additions & 6 deletions lib/src/chart/bar_chart/bar_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@ import 'package:flutter/cupertino.dart';
class BarChart extends ImplicitlyAnimatedWidget {
/// [data] determines how the [BarChart] should be look like,
/// when you make any change in the [BarChartData], it updates
/// new values with animation, and duration is [swapAnimationDuration].
/// also you can change the [swapAnimationCurve]
/// new values with animation, and duration is [duration].
/// also you can change the [curve]
/// which default is [Curves.linear].
const BarChart(
this.data, {
this.chartRendererKey,
super.key,
Duration swapAnimationDuration = const Duration(milliseconds: 150),
Curve swapAnimationCurve = Curves.linear,
@Deprecated('Please use duration instead') Duration? swapAnimationDuration,
Duration duration = const Duration(milliseconds: 150),
@Deprecated('Please use curve instead') Curve? swapAnimationCurve,
Curve curve = Curves.linear,
}) : super(
duration: swapAnimationDuration,
curve: swapAnimationCurve,
duration: swapAnimationDuration ?? duration,
curve: swapAnimationCurve ?? curve,
);

/// Determines how the [BarChart] should be look like.
Expand Down
4 changes: 2 additions & 2 deletions lib/src/chart/line_chart/line_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import 'package:flutter/material.dart';
class LineChart extends ImplicitlyAnimatedWidget {
/// [data] determines how the [LineChart] should be look like,
/// when you make any change in the [LineChartData], it updates
/// new values with animation, and duration is [swapAnimationDuration].
/// also you can change the [swapAnimationCurve]
/// new values with animation, and duration is [duration].
/// also you can change the [curve]
/// which default is [Curves.linear].
const LineChart(
this.data, {
Expand Down
15 changes: 9 additions & 6 deletions lib/src/chart/pie_chart/pie_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ import 'package:flutter/material.dart';
class PieChart extends ImplicitlyAnimatedWidget {
/// [data] determines how the [PieChart] should be look like,
/// when you make any change in the [PieChartData], it updates
/// new values with animation, and duration is [swapAnimationDuration].
/// also you can change the [swapAnimationCurve]
/// new values with animation, and duration is [duration].
/// also you can change the [curve]
/// which default is [Curves.linear].
const PieChart(
this.data, {
super.key,
Duration swapAnimationDuration = defaultDuration,
Curve swapAnimationCurve = Curves.linear,
@Deprecated('Please use duration instead') Duration? swapAnimationDuration,
Duration duration = const Duration(milliseconds: 150),
@Deprecated('Please use curve instead') Curve? swapAnimationCurve,
Curve curve = Curves.linear,
}) : super(
duration: swapAnimationDuration,
curve: swapAnimationCurve,
duration: swapAnimationDuration ?? duration,
curve: swapAnimationCurve ?? curve,
);

/// Default duration to reuse externally.
Expand Down Expand Up @@ -86,6 +88,7 @@ class BadgeWidgetsDelegate extends MultiChildLayoutDelegate {
required this.badgeWidgetsCount,
required this.badgeWidgetsOffsets,
});

final int badgeWidgetsCount;
final Map<int, Offset> badgeWidgetsOffsets;

Expand Down
14 changes: 8 additions & 6 deletions lib/src/chart/radar_chart/radar_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ import 'package:flutter/material.dart';
class RadarChart extends ImplicitlyAnimatedWidget {
/// [data] determines how the [RadarChart] should be look like,
/// when you make any change in the [RadarChart], it updates
/// new values with animation, and duration is [swapAnimationDuration].
/// also you can change the [swapAnimationCurve]
/// new values with animation, and duration is [duration].
/// also you can change the [curve]
/// which default is [Curves.linear].
const RadarChart(
this.data, {
super.key,
Duration swapAnimationDuration = const Duration(milliseconds: 150),
Curve swapAnimationCurve = Curves.linear,
@Deprecated('Please use duration instead') Duration? swapAnimationDuration,
Duration duration = const Duration(milliseconds: 150),
@Deprecated('Please use curve instead') Curve? swapAnimationCurve,
Curve curve = Curves.linear,
}) : super(
duration: swapAnimationDuration,
curve: swapAnimationCurve,
duration: swapAnimationDuration ?? duration,
curve: swapAnimationCurve ?? curve,
);

/// Determines how the [RadarChart] should be look like.
Expand Down
16 changes: 10 additions & 6 deletions lib/src/chart/scatter_chart/scatter_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@ import 'package:flutter/cupertino.dart';
class ScatterChart extends ImplicitlyAnimatedWidget {
/// [data] determines how the [ScatterChart] should be look like,
/// when you make any change in the [ScatterChartData], it updates
/// new values with animation, and duration is [swapAnimationDuration].
/// also you can change the [swapAnimationCurve]
/// new values with animation, and duration is [duration].
/// also you can change the [curve]
/// which default is [Curves.linear].
const ScatterChart(
this.data, {
this.chartRendererKey,
super.key,
Duration swapAnimationDuration = const Duration(milliseconds: 150),
Curve swapAnimationCurve = Curves.linear,
@Deprecated('Please use duration instead')
Duration? swapAnimationDuration,
Duration duration = const Duration(milliseconds: 150),
@Deprecated('Please use curve instead')
Curve? swapAnimationCurve,
Curve curve = Curves.linear,
}) : super(
duration: swapAnimationDuration,
curve: swapAnimationCurve,
duration: swapAnimationDuration ?? duration,
curve: swapAnimationCurve ?? curve,
);

/// Determines how the [ScatterChart] should be look like.
Expand Down
6 changes: 3 additions & 3 deletions repo_files/documentations/bar_chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ BarChart(
BarChartData(
// read about it in the BarChartData section
),
swapAnimationDuration: Duration(milliseconds: 150), // Optional
swapAnimationCurve: Curves.linear, // Optional
duration: Duration(milliseconds: 150), // Optional
curve: Curves.linear, // Optional
);
```

### Implicit Animations
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.
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.

### BarChartData
|PropName |Description |default value|
Expand Down
6 changes: 3 additions & 3 deletions repo_files/documentations/pie_chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ PieChart(
PieChartData(
// read about it in the PieChartData section
),
swapAnimationDuration: Duration(milliseconds: 150), // Optional
swapAnimationCurve: Curves.linear, // Optional
duration: Duration(milliseconds: 150), // Optional
curve: Curves.linear, // Optional
);
```

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


### Implicit Animations
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.
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.

### PieChartData
|PropName |Description |default value|
Expand Down
6 changes: 3 additions & 3 deletions repo_files/documentations/scatter_chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ ScatterChart(
ScatterChartData(
// read about it in the ScatterChartData section
),
swapAnimationDuration: Duration(milliseconds: 150), // Optional
swapAnimationCurve: Curves.linear, // Optional
duration: Duration(milliseconds: 150), // Optional
curve: Curves.linear, // Optional
);
```

### Implicit Animations
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.
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.

### ScatterChartData
|PropName |Description |default value|
Expand Down

0 comments on commit ef1c016

Please sign in to comment.