diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 1c5e7991d..46149aea2 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -5,12 +5,12 @@ Don't forget that `open-source` makes no sense without contributors. No matter h
This file is intended to be a guide for those who are interested in contributing to the FL Chart.
-#### Below are the people who has contributed to the FL Chart. We hope we have your picture here soon.
+#### Below are the people who have contributed to the FL Chart. We hope we have your picture here soon.
[![](https://opencollective.com/fl_chart/contributors.svg?width=890&button=false)](https://github.com/imaNNeo/fl_chart/graphs/contributors)
## Let's get Started
-Make sure you have Flutter installed and on your path (follow [installation guide](https://docs.flutter.dev/get-started/install)).
+Make sure you have Flutter installed and on your path (follow the [installation guide](https://docs.flutter.dev/get-started/install)).
Follow these steps to clone FL Chart and set up the development environment:
@@ -27,7 +27,7 @@ Follow these steps to clone FL Chart and set up the development environment:
## Before Modifying the Code
If the work you intend to do is non-trivial, it is necessary to open
-an issue before starting writing your code. This helps us and the
+an issue before starting to write your code. This helps us and the
community to discuss the issue and choose what is deemed to be the
best solution.
@@ -39,7 +39,7 @@ In case you couldn't find any issue, it's better to create an issue to explain w
We have a *_chart_painter.dart class per each chart type. It draws elements into the Canvas.
We made the CanvasWrapper class, because we wanted to test draw functions.
CanvasWrapper class holds a canvas and all draw functions proxies through it.
-You should use it for drawing on the canvas, Instead of direct accessing to canvas.
+You should use it for drawing on the canvas, Instead of directly accessing the canvas.
It makes draw functions testable.
@@ -50,7 +50,7 @@ It makes draw functions testable.
While you are developing your branch, It is common that your branch gets outdated and you need to update your branch with the `master` branch.
To do that, please use `rebase` instead of `merge`. Because when you finish the PR, we must `rebase` your branch and merge it with the master.
The reason that we prefer `rebase` over `merge` is the simplicity of the commit history. It allows us to have sequential commits in the `master`
-[This article](https://www.atlassian.com/git/tutorials/merging-vs-rebasing) might help to understand it better.
+[This article](https://www.atlassian.com/git/tutorials/merging-vs-rebasing) might help you understand it better.
## Checking Your Code's Quality
@@ -60,7 +60,7 @@ correctly and meets our guidelines. Our guidelines are:
You can simply run `make checkstyle`, and if you faced any formatting problem, run `make format`.
##### Run `make checkstyle` to ensure that your code is formatted correctly
-- It runs `flutter analyze` to verify that there is no any warning or error.
+- It runs `flutter analyze` to verify that there are no warnings or errors.
- It runs `dart format --set-exit-if-changed --dry-run .` to verify that code has formatted correctly.
#### Run `make format` to reformat the code
@@ -74,9 +74,9 @@ You can simply run `make checkstyle`, and if you faced any formatting problem, r
- It runs both `make runTests` and then `make checkstyle` sequentially with a single command.
## Test coverage (unit tests)
-We should write unit-test for our written code. If you are not familiar with unit-tests, please start from [here](https://docs.flutter.dev/cookbook/testing/unit/introduction).
+We should write unit tests for our written code. If you are not familiar with unit-tests, please start from [here](https://docs.flutter.dev/cookbook/testing/unit/introduction).
-[Mockito](https://pub.dev/packages/mockito) is the library that we use to mock our classes, please read more about it from their docs [here](https://github.com/dart-lang/mockito#lets-create-mocks).
+[Mockito](https://pub.dev/packages/mockito) is the library that we use to mock our classes. Please read more about it in their docs [here](https://github.com/dart-lang/mockito#lets-create-mocks).
Our code coverage is calculated by [Codecov](https://app.codecov.io/gh/imaNNeo/fl_chart) (Our coverage is [![codecov](https://codecov.io/gh/imaNNeo/fl_chart/branch/main/graph/badge.svg?token=XBhsIZBbZG)](https://codecov.io/gh/imaNNeo/fl_chart)
at the moment)
@@ -88,12 +88,12 @@ Please make sure that your code is **not decreasing** the coverage.
## Creating a Pull Request
Congratulations! Your code meets all of our guidelines :100:. Now you have to
-submit a pull request (or PR for short) to us. These are the steps you should
+submit a pull request (PR for short) to us. These are the steps you should
follow when creating a PR:
- Make a descriptive title that summarizes what changes were in the PR.
-- Mention the issues that you are fixing (if doesn't exist, try to make one and explain the issue clearly)
+- Mention the issues that you are fixing (if they don't exist, try to make one and explain the issue clearly)
- Change your code according to feedback (if any).
diff --git a/example/lib/presentation/menu/app_menu.dart b/example/lib/presentation/menu/app_menu.dart
index 51fcd2daf..f7ee854a6 100644
--- a/example/lib/presentation/menu/app_menu.dart
+++ b/example/lib/presentation/menu/app_menu.dart
@@ -19,12 +19,12 @@ class AppMenu extends StatefulWidget {
final VoidCallback? onBannerClicked;
const AppMenu({
- Key? key,
+ super.key,
required this.menuItems,
required this.currentSelectedIndex,
required this.onItemSelected,
required this.onBannerClicked,
- }) : super(key: key);
+ });
@override
AppMenuState createState() => AppMenuState();
diff --git a/example/lib/presentation/menu/fl_chart_banner.dart b/example/lib/presentation/menu/fl_chart_banner.dart
index 009b69a08..27558da00 100644
--- a/example/lib/presentation/menu/fl_chart_banner.dart
+++ b/example/lib/presentation/menu/fl_chart_banner.dart
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
class FlChartBanner extends StatelessWidget {
- const FlChartBanner({Key? key}) : super(key: key);
+ const FlChartBanner({super.key});
@override
Widget build(BuildContext context) {
diff --git a/example/lib/presentation/menu/menu_row.dart b/example/lib/presentation/menu/menu_row.dart
index 63db6e8df..4606f8c4c 100644
--- a/example/lib/presentation/menu/menu_row.dart
+++ b/example/lib/presentation/menu/menu_row.dart
@@ -10,13 +10,13 @@ class MenuRow extends StatefulWidget {
final VoidCallback onDocumentsTap;
const MenuRow({
- Key? key,
+ super.key,
required this.text,
required this.svgPath,
required this.isSelected,
required this.onTap,
required this.onDocumentsTap,
- }) : super(key: key);
+ });
@override
State createState() => _MenuRowState();
@@ -77,9 +77,8 @@ class _MenuRowState extends State {
class _DocumentationIcon extends StatelessWidget {
const _DocumentationIcon({
- Key? key,
required this.onTap,
- }) : super(key: key);
+ });
final VoidCallback onTap;
@override
diff --git a/example/lib/presentation/pages/chart_samples_page.dart b/example/lib/presentation/pages/chart_samples_page.dart
index 3f3ad4079..056fef5bd 100644
--- a/example/lib/presentation/pages/chart_samples_page.dart
+++ b/example/lib/presentation/pages/chart_samples_page.dart
@@ -11,9 +11,9 @@ class ChartSamplesPage extends StatelessWidget {
final samples = ChartSamples.samples;
ChartSamplesPage({
- Key? key,
+ super.key,
required this.chartType,
- }) : super(key: key);
+ });
@override
Widget build(BuildContext context) {
diff --git a/example/lib/presentation/pages/home_page.dart b/example/lib/presentation/pages/home_page.dart
index d1e2b02d3..87e3a57c0 100644
--- a/example/lib/presentation/pages/home_page.dart
+++ b/example/lib/presentation/pages/home_page.dart
@@ -11,9 +11,9 @@ import 'chart_samples_page.dart';
class HomePage extends StatelessWidget {
HomePage({
- Key? key,
+ super.key,
required this.showingChartType,
- }) : super(key: key) {
+ }) {
_initMenuItems();
}
diff --git a/example/lib/presentation/router/app_router.dart b/example/lib/presentation/router/app_router.dart
index 4ae2b6769..80dc3e199 100644
--- a/example/lib/presentation/router/app_router.dart
+++ b/example/lib/presentation/router/app_router.dart
@@ -13,20 +13,18 @@ final appRouterConfig = GoRouter(
return '/${ChartType.values.first.name}';
},
),
- ...ChartType.values
- .map(
- (ChartType chartType) => GoRoute(
- path: '/${chartType.name}',
- pageBuilder: (BuildContext context, GoRouterState state) =>
- MaterialPage(
- /// We set a key for HomePage to prevent recreate it
- /// when user choose a new chart type to show
- key: const ValueKey('home_page'),
- child: HomePage(showingChartType: chartType),
- ),
- ),
- )
- .toList(),
+ ...ChartType.values.map(
+ (ChartType chartType) => GoRoute(
+ path: '/${chartType.name}',
+ pageBuilder: (BuildContext context, GoRouterState state) =>
+ MaterialPage(
+ /// We set a key for HomePage to prevent recreate it
+ /// when user choose a new chart type to show
+ key: const ValueKey('home_page'),
+ child: HomePage(showingChartType: chartType),
+ ),
+ ),
+ ),
GoRoute(
path: '/:any',
builder: (context, state) => Container(color: AppColors.pageBackground),
diff --git a/example/lib/presentation/widgets/chart_holder.dart b/example/lib/presentation/widgets/chart_holder.dart
index 3428d0838..93a4a39c2 100644
--- a/example/lib/presentation/widgets/chart_holder.dart
+++ b/example/lib/presentation/widgets/chart_holder.dart
@@ -7,9 +7,9 @@ class ChartHolder extends StatelessWidget {
final ChartSample chartSample;
const ChartHolder({
- Key? key,
+ super.key,
required this.chartSample,
- }) : super(key: key);
+ });
@override
Widget build(BuildContext context) {
diff --git a/lib/src/chart/bar_chart/bar_chart_data.dart b/lib/src/chart/bar_chart/bar_chart_data.dart
index 70fd27580..1a07107d0 100644
--- a/lib/src/chart/bar_chart/bar_chart_data.dart
+++ b/lib/src/chart/bar_chart/bar_chart_data.dart
@@ -94,23 +94,22 @@ class BarChartData extends AxisChartData with EquatableMixin {
double? baselineY,
Color? backgroundColor,
ExtraLinesData? extraLinesData,
- }) {
- return BarChartData(
- barGroups: barGroups ?? this.barGroups,
- groupsSpace: groupsSpace ?? this.groupsSpace,
- alignment: alignment ?? this.alignment,
- titlesData: titlesData ?? this.titlesData,
- rangeAnnotations: rangeAnnotations ?? this.rangeAnnotations,
- barTouchData: barTouchData ?? this.barTouchData,
- gridData: gridData ?? this.gridData,
- borderData: borderData ?? this.borderData,
- maxY: maxY ?? this.maxY,
- minY: minY ?? this.minY,
- baselineY: baselineY ?? this.baselineY,
- backgroundColor: backgroundColor ?? this.backgroundColor,
- extraLinesData: extraLinesData ?? this.extraLinesData,
- );
- }
+ }) =>
+ BarChartData(
+ barGroups: barGroups ?? this.barGroups,
+ groupsSpace: groupsSpace ?? this.groupsSpace,
+ alignment: alignment ?? this.alignment,
+ titlesData: titlesData ?? this.titlesData,
+ rangeAnnotations: rangeAnnotations ?? this.rangeAnnotations,
+ barTouchData: barTouchData ?? this.barTouchData,
+ gridData: gridData ?? this.gridData,
+ borderData: borderData ?? this.borderData,
+ maxY: maxY ?? this.maxY,
+ minY: minY ?? this.minY,
+ baselineY: baselineY ?? this.baselineY,
+ backgroundColor: backgroundColor ?? this.backgroundColor,
+ extraLinesData: extraLinesData ?? this.extraLinesData,
+ );
/// Lerps a [BaseChartData] based on [t] value, check [Tween.lerp].
@override
@@ -243,35 +242,33 @@ class BarChartGroupData with EquatableMixin {
List? barRods,
double? barsSpace,
List? showingTooltipIndicators,
- }) {
- return BarChartGroupData(
- x: x ?? this.x,
- groupVertically: groupVertically ?? this.groupVertically,
- barRods: barRods ?? this.barRods,
- barsSpace: barsSpace ?? this.barsSpace,
- showingTooltipIndicators:
- showingTooltipIndicators ?? this.showingTooltipIndicators,
- );
- }
+ }) =>
+ BarChartGroupData(
+ x: x ?? this.x,
+ groupVertically: groupVertically ?? this.groupVertically,
+ barRods: barRods ?? this.barRods,
+ barsSpace: barsSpace ?? this.barsSpace,
+ showingTooltipIndicators:
+ showingTooltipIndicators ?? this.showingTooltipIndicators,
+ );
/// Lerps a [BarChartGroupData] based on [t] value, check [Tween.lerp].
static BarChartGroupData lerp(
BarChartGroupData a,
BarChartGroupData b,
double t,
- ) {
- return BarChartGroupData(
- x: (a.x + (b.x - a.x) * t).round(),
- groupVertically: b.groupVertically,
- barRods: lerpBarChartRodDataList(a.barRods, b.barRods, t),
- barsSpace: lerpDouble(a.barsSpace, b.barsSpace, t),
- showingTooltipIndicators: lerpIntList(
- a.showingTooltipIndicators,
- b.showingTooltipIndicators,
- t,
- ),
- );
- }
+ ) =>
+ BarChartGroupData(
+ x: (a.x + (b.x - a.x) * t).round(),
+ groupVertically: b.groupVertically,
+ barRods: lerpBarChartRodDataList(a.barRods, b.barRods, t),
+ barsSpace: lerpDouble(a.barsSpace, b.barsSpace, t),
+ showingTooltipIndicators: lerpIntList(
+ a.showingTooltipIndicators,
+ b.showingTooltipIndicators,
+ t,
+ ),
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -386,42 +383,40 @@ class BarChartRodData with EquatableMixin {
BorderSide? borderSide,
BackgroundBarChartRodData? backDrawRodData,
List? rodStackItems,
- }) {
- return BarChartRodData(
- fromY: fromY ?? this.fromY,
- toY: toY ?? this.toY,
- color: color ?? this.color,
- gradient: gradient ?? this.gradient,
- width: width ?? this.width,
- borderRadius: borderRadius ?? this.borderRadius,
- borderDashArray: borderDashArray,
- borderSide: borderSide ?? this.borderSide,
- backDrawRodData: backDrawRodData ?? this.backDrawRodData,
- rodStackItems: rodStackItems ?? this.rodStackItems,
- );
- }
+ }) =>
+ BarChartRodData(
+ fromY: fromY ?? this.fromY,
+ toY: toY ?? this.toY,
+ color: color ?? this.color,
+ gradient: gradient ?? this.gradient,
+ width: width ?? this.width,
+ borderRadius: borderRadius ?? this.borderRadius,
+ borderDashArray: borderDashArray,
+ borderSide: borderSide ?? this.borderSide,
+ backDrawRodData: backDrawRodData ?? this.backDrawRodData,
+ rodStackItems: rodStackItems ?? this.rodStackItems,
+ );
/// Lerps a [BarChartRodData] based on [t] value, check [Tween.lerp].
- static BarChartRodData lerp(BarChartRodData a, BarChartRodData b, double t) {
- return BarChartRodData(
- // ignore: invalid_use_of_protected_member
- gradient: a.gradient?.lerpTo(b.gradient, t),
- color: Color.lerp(a.color, b.color, t),
- width: lerpDouble(a.width, b.width, t),
- borderRadius: BorderRadius.lerp(a.borderRadius, b.borderRadius, t),
- borderDashArray: lerpIntList(a.borderDashArray, b.borderDashArray, t),
- borderSide: BorderSide.lerp(a.borderSide, b.borderSide, t),
- fromY: lerpDouble(a.fromY, b.fromY, t),
- toY: lerpDouble(a.toY, b.toY, t)!,
- backDrawRodData: BackgroundBarChartRodData.lerp(
- a.backDrawRodData,
- b.backDrawRodData,
- t,
- ),
- rodStackItems:
- lerpBarChartRodStackList(a.rodStackItems, b.rodStackItems, t),
- );
- }
+ static BarChartRodData lerp(BarChartRodData a, BarChartRodData b, double t) =>
+ BarChartRodData(
+ // ignore: invalid_use_of_protected_member
+ gradient: a.gradient?.lerpTo(b.gradient, t),
+ color: Color.lerp(a.color, b.color, t),
+ width: lerpDouble(a.width, b.width, t),
+ borderRadius: BorderRadius.lerp(a.borderRadius, b.borderRadius, t),
+ borderDashArray: lerpIntList(a.borderDashArray, b.borderDashArray, t),
+ borderSide: BorderSide.lerp(a.borderSide, b.borderSide, t),
+ fromY: lerpDouble(a.fromY, b.fromY, t),
+ toY: lerpDouble(a.toY, b.toY, t)!,
+ backDrawRodData: BackgroundBarChartRodData.lerp(
+ a.backDrawRodData,
+ b.backDrawRodData,
+ t,
+ ),
+ rodStackItems:
+ lerpBarChartRodStackList(a.rodStackItems, b.rodStackItems, t),
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -483,28 +478,26 @@ class BarChartRodStackItem with EquatableMixin {
double? toY,
Color? color,
BorderSide? borderSide,
- }) {
- return BarChartRodStackItem(
- fromY ?? this.fromY,
- toY ?? this.toY,
- color ?? this.color,
- borderSide ?? this.borderSide,
- );
- }
+ }) =>
+ BarChartRodStackItem(
+ fromY ?? this.fromY,
+ toY ?? this.toY,
+ color ?? this.color,
+ borderSide ?? this.borderSide,
+ );
/// Lerps a [BarChartRodStackItem] based on [t] value, check [Tween.lerp].
static BarChartRodStackItem lerp(
BarChartRodStackItem a,
BarChartRodStackItem b,
double t,
- ) {
- return BarChartRodStackItem(
- lerpDouble(a.fromY, b.fromY, t)!,
- lerpDouble(a.toY, b.toY, t)!,
- Color.lerp(a.color, b.color, t)!,
- BorderSide.lerp(a.borderSide, b.borderSide, t),
- );
- }
+ ) =>
+ BarChartRodStackItem(
+ lerpDouble(a.fromY, b.fromY, t)!,
+ lerpDouble(a.toY, b.toY, t)!,
+ Color.lerp(a.color, b.color, t)!,
+ BorderSide.lerp(a.borderSide, b.borderSide, t),
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -557,16 +550,15 @@ class BackgroundBarChartRodData with EquatableMixin {
BackgroundBarChartRodData a,
BackgroundBarChartRodData b,
double t,
- ) {
- return BackgroundBarChartRodData(
- fromY: lerpDouble(a.fromY, b.fromY, t),
- toY: lerpDouble(a.toY, b.toY, t),
- color: Color.lerp(a.color, b.color, t),
- // ignore: invalid_use_of_protected_member
- gradient: a.gradient?.lerpTo(b.gradient, t),
- show: b.show,
- );
- }
+ ) =>
+ BackgroundBarChartRodData(
+ fromY: lerpDouble(a.fromY, b.fromY, t),
+ toY: lerpDouble(a.toY, b.toY, t),
+ color: Color.lerp(a.color, b.color, t),
+ // ignore: invalid_use_of_protected_member
+ gradient: a.gradient?.lerpTo(b.gradient, t),
+ show: b.show,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -645,19 +637,18 @@ class BarTouchData extends FlTouchData with EquatableMixin {
EdgeInsets? touchExtraThreshold,
bool? allowTouchBarBackDraw,
bool? handleBuiltInTouches,
- }) {
- return BarTouchData(
- enabled: enabled ?? this.enabled,
- touchCallback: touchCallback ?? this.touchCallback,
- mouseCursorResolver: mouseCursorResolver ?? this.mouseCursorResolver,
- longPressDuration: longPressDuration ?? this.longPressDuration,
- touchTooltipData: touchTooltipData ?? this.touchTooltipData,
- touchExtraThreshold: touchExtraThreshold ?? this.touchExtraThreshold,
- allowTouchBarBackDraw:
- allowTouchBarBackDraw ?? this.allowTouchBarBackDraw,
- handleBuiltInTouches: handleBuiltInTouches ?? this.handleBuiltInTouches,
- );
- }
+ }) =>
+ BarTouchData(
+ enabled: enabled ?? this.enabled,
+ touchCallback: touchCallback ?? this.touchCallback,
+ mouseCursorResolver: mouseCursorResolver ?? this.mouseCursorResolver,
+ longPressDuration: longPressDuration ?? this.longPressDuration,
+ touchTooltipData: touchTooltipData ?? this.touchTooltipData,
+ touchExtraThreshold: touchExtraThreshold ?? this.touchExtraThreshold,
+ allowTouchBarBackDraw:
+ allowTouchBarBackDraw ?? this.allowTouchBarBackDraw,
+ handleBuiltInTouches: handleBuiltInTouches ?? this.handleBuiltInTouches,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -864,9 +855,8 @@ typedef GetBarTooltipColor = Color Function(
);
/// Default implementation for [BarTouchTooltipData.getTooltipColor].
-Color defaultBarTooltipColor(BarChartGroupData group) {
- return Colors.blueGrey.darken(15);
-}
+Color defaultBarTooltipColor(BarChartGroupData group) =>
+ Colors.blueGrey.darken(15);
/// Holds information about touch response in the [BarChart].
///
@@ -884,11 +874,10 @@ class BarTouchResponse extends BaseTouchResponse {
/// and replaces provided values.
BarTouchResponse copyWith({
BarTouchedSpot? spot,
- }) {
- return BarTouchResponse(
- spot ?? this.spot,
- );
- }
+ }) =>
+ BarTouchResponse(
+ spot ?? this.spot,
+ );
}
/// It gives you information about the touched spot.
diff --git a/lib/src/chart/base/axis_chart/axis_chart_data.dart b/lib/src/chart/base/axis_chart/axis_chart_data.dart
index 156d98df1..07570fd3b 100644
--- a/lib/src/chart/base/axis_chart/axis_chart_data.dart
+++ b/lib/src/chart/base/axis_chart/axis_chart_data.dart
@@ -189,16 +189,14 @@ class SideTitles with EquatableMixin {
final bool maxIncluded;
/// Lerps a [SideTitles] based on [t] value, check [Tween.lerp].
- static SideTitles lerp(SideTitles a, SideTitles b, double t) {
- return SideTitles(
- showTitles: b.showTitles,
- getTitlesWidget: b.getTitlesWidget,
- reservedSize: lerpDouble(a.reservedSize, b.reservedSize, t)!,
- interval: lerpDouble(a.interval, b.interval, t),
- minIncluded: b.minIncluded,
- maxIncluded: b.maxIncluded,
- );
- }
+ static SideTitles lerp(SideTitles a, SideTitles b, double t) => SideTitles(
+ showTitles: b.showTitles,
+ getTitlesWidget: b.getTitlesWidget,
+ reservedSize: lerpDouble(a.reservedSize, b.reservedSize, t)!,
+ interval: lerpDouble(a.interval, b.interval, t),
+ minIncluded: b.minIncluded,
+ maxIncluded: b.maxIncluded,
+ );
/// Copies current [SideTitles] to a new [SideTitles],
/// and replaces provided values.
@@ -209,16 +207,15 @@ class SideTitles with EquatableMixin {
double? interval,
bool? minIncluded,
bool? maxIncluded,
- }) {
- return SideTitles(
- showTitles: showTitles ?? this.showTitles,
- getTitlesWidget: getTitlesWidget ?? this.getTitlesWidget,
- reservedSize: reservedSize ?? this.reservedSize,
- interval: interval ?? this.interval,
- minIncluded: minIncluded ?? this.minIncluded,
- maxIncluded: maxIncluded ?? this.maxIncluded,
- );
- }
+ }) =>
+ SideTitles(
+ showTitles: showTitles ?? this.showTitles,
+ getTitlesWidget: getTitlesWidget ?? this.getTitlesWidget,
+ reservedSize: reservedSize ?? this.reservedSize,
+ interval: interval ?? this.interval,
+ minIncluded: minIncluded ?? this.minIncluded,
+ maxIncluded: maxIncluded ?? this.maxIncluded,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -342,14 +339,12 @@ class AxisTitles with EquatableMixin {
sideTitles.showTitles && sideTitles.reservedSize != 0;
/// Lerps a [AxisTitles] based on [t] value, check [Tween.lerp].
- static AxisTitles lerp(AxisTitles a, AxisTitles b, double t) {
- return AxisTitles(
- axisNameWidget: b.axisNameWidget,
- axisNameSize: lerpDouble(a.axisNameSize, b.axisNameSize, t)!,
- sideTitles: SideTitles.lerp(a.sideTitles, b.sideTitles, t),
- drawBelowEverything: b.drawBelowEverything,
- );
- }
+ static AxisTitles lerp(AxisTitles a, AxisTitles b, double t) => AxisTitles(
+ axisNameWidget: b.axisNameWidget,
+ axisNameSize: lerpDouble(a.axisNameSize, b.axisNameSize, t)!,
+ sideTitles: SideTitles.lerp(a.sideTitles, b.sideTitles, t),
+ drawBelowEverything: b.drawBelowEverything,
+ );
/// Copies current [SideTitles] to a new [SideTitles],
/// and replaces provided values.
@@ -358,14 +353,13 @@ class AxisTitles with EquatableMixin {
double? axisNameSize,
SideTitles? sideTitles,
bool? drawBelowEverything,
- }) {
- return AxisTitles(
- axisNameWidget: axisNameWidget ?? this.axisNameWidget,
- axisNameSize: axisNameSize ?? this.axisNameSize,
- sideTitles: sideTitles ?? this.sideTitles,
- drawBelowEverything: drawBelowEverything ?? this.drawBelowEverything,
- );
- }
+ }) =>
+ AxisTitles(
+ axisNameWidget: axisNameWidget ?? this.axisNameWidget,
+ axisNameSize: axisNameSize ?? this.axisNameSize,
+ sideTitles: sideTitles ?? this.sideTitles,
+ drawBelowEverything: drawBelowEverything ?? this.drawBelowEverything,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -417,15 +411,14 @@ class FlTitlesData with EquatableMixin {
final AxisTitles bottomTitles;
/// Lerps a [FlTitlesData] based on [t] value, check [Tween.lerp].
- static FlTitlesData lerp(FlTitlesData a, FlTitlesData b, double t) {
- return FlTitlesData(
- show: b.show,
- leftTitles: AxisTitles.lerp(a.leftTitles, b.leftTitles, t),
- rightTitles: AxisTitles.lerp(a.rightTitles, b.rightTitles, t),
- bottomTitles: AxisTitles.lerp(a.bottomTitles, b.bottomTitles, t),
- topTitles: AxisTitles.lerp(a.topTitles, b.topTitles, t),
- );
- }
+ static FlTitlesData lerp(FlTitlesData a, FlTitlesData b, double t) =>
+ FlTitlesData(
+ show: b.show,
+ leftTitles: AxisTitles.lerp(a.leftTitles, b.leftTitles, t),
+ rightTitles: AxisTitles.lerp(a.rightTitles, b.rightTitles, t),
+ bottomTitles: AxisTitles.lerp(a.bottomTitles, b.bottomTitles, t),
+ topTitles: AxisTitles.lerp(a.topTitles, b.topTitles, t),
+ );
/// Copies current [FlTitlesData] to a new [FlTitlesData],
/// and replaces provided values.
@@ -435,15 +428,14 @@ class FlTitlesData with EquatableMixin {
AxisTitles? topTitles,
AxisTitles? rightTitles,
AxisTitles? bottomTitles,
- }) {
- return FlTitlesData(
- show: show ?? this.show,
- leftTitles: leftTitles ?? this.leftTitles,
- topTitles: topTitles ?? this.topTitles,
- rightTitles: rightTitles ?? this.rightTitles,
- bottomTitles: bottomTitles ?? this.bottomTitles,
- );
- }
+ }) =>
+ FlTitlesData(
+ show: show ?? this.show,
+ leftTitles: leftTitles ?? this.leftTitles,
+ topTitles: topTitles ?? this.topTitles,
+ rightTitles: rightTitles ?? this.rightTitles,
+ bottomTitles: bottomTitles ?? this.bottomTitles,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -465,6 +457,7 @@ class FlSpot {
/// [y] determines cartesian (axis based) vertically position
/// 0 means most bottom point of the chart
const FlSpot(this.x, this.y);
+
final double x;
final double y;
@@ -473,12 +466,11 @@ class FlSpot {
FlSpot copyWith({
double? x,
double? y,
- }) {
- return FlSpot(
- x ?? this.x,
- y ?? this.y,
- );
- }
+ }) =>
+ FlSpot(
+ x ?? this.x,
+ y ?? this.y,
+ );
///Prints x and y coordinates of FlSpot list
@override
@@ -603,20 +595,18 @@ class FlGridData with EquatableMixin {
final CheckToShowGrid checkToShowVerticalLine;
/// Lerps a [FlGridData] based on [t] value, check [Tween.lerp].
- static FlGridData lerp(FlGridData a, FlGridData b, double t) {
- return FlGridData(
- show: b.show,
- drawHorizontalLine: b.drawHorizontalLine,
- horizontalInterval:
- lerpDouble(a.horizontalInterval, b.horizontalInterval, t),
- getDrawingHorizontalLine: b.getDrawingHorizontalLine,
- checkToShowHorizontalLine: b.checkToShowHorizontalLine,
- drawVerticalLine: b.drawVerticalLine,
- verticalInterval: lerpDouble(a.verticalInterval, b.verticalInterval, t),
- getDrawingVerticalLine: b.getDrawingVerticalLine,
- checkToShowVerticalLine: b.checkToShowVerticalLine,
- );
- }
+ static FlGridData lerp(FlGridData a, FlGridData b, double t) => FlGridData(
+ show: b.show,
+ drawHorizontalLine: b.drawHorizontalLine,
+ horizontalInterval:
+ lerpDouble(a.horizontalInterval, b.horizontalInterval, t),
+ getDrawingHorizontalLine: b.getDrawingHorizontalLine,
+ checkToShowHorizontalLine: b.checkToShowHorizontalLine,
+ drawVerticalLine: b.drawVerticalLine,
+ verticalInterval: lerpDouble(a.verticalInterval, b.verticalInterval, t),
+ getDrawingVerticalLine: b.getDrawingVerticalLine,
+ checkToShowVerticalLine: b.checkToShowVerticalLine,
+ );
/// Copies current [FlGridData] to a new [FlGridData],
/// and replaces provided values.
@@ -630,23 +620,22 @@ class FlGridData with EquatableMixin {
double? verticalInterval,
GetDrawingGridLine? getDrawingVerticalLine,
CheckToShowGrid? checkToShowVerticalLine,
- }) {
- return FlGridData(
- show: show ?? this.show,
- drawHorizontalLine: drawHorizontalLine ?? this.drawHorizontalLine,
- horizontalInterval: horizontalInterval ?? this.horizontalInterval,
- getDrawingHorizontalLine:
- getDrawingHorizontalLine ?? this.getDrawingHorizontalLine,
- checkToShowHorizontalLine:
- checkToShowHorizontalLine ?? this.checkToShowHorizontalLine,
- drawVerticalLine: drawVerticalLine ?? this.drawVerticalLine,
- verticalInterval: verticalInterval ?? this.verticalInterval,
- getDrawingVerticalLine:
- getDrawingVerticalLine ?? this.getDrawingVerticalLine,
- checkToShowVerticalLine:
- checkToShowVerticalLine ?? this.checkToShowVerticalLine,
- );
- }
+ }) =>
+ FlGridData(
+ show: show ?? this.show,
+ drawHorizontalLine: drawHorizontalLine ?? this.drawHorizontalLine,
+ horizontalInterval: horizontalInterval ?? this.horizontalInterval,
+ getDrawingHorizontalLine:
+ getDrawingHorizontalLine ?? this.getDrawingHorizontalLine,
+ checkToShowHorizontalLine:
+ checkToShowHorizontalLine ?? this.checkToShowHorizontalLine,
+ drawVerticalLine: drawVerticalLine ?? this.drawVerticalLine,
+ verticalInterval: verticalInterval ?? this.verticalInterval,
+ getDrawingVerticalLine:
+ getDrawingVerticalLine ?? this.getDrawingVerticalLine,
+ checkToShowVerticalLine:
+ checkToShowVerticalLine ?? this.checkToShowVerticalLine,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -667,9 +656,7 @@ class FlGridData with EquatableMixin {
typedef CheckToShowGrid = bool Function(double value);
/// Shows all lines.
-bool showAllGrids(double value) {
- return true;
-}
+bool showAllGrids(double value) => true;
/// Determines the appearance of specified line.
///
@@ -678,13 +665,11 @@ bool showAllGrids(double value) {
typedef GetDrawingGridLine = FlLine Function(double value);
/// Returns a grey line for all values.
-FlLine defaultGridLine(double value) {
- return const FlLine(
- color: Colors.blueGrey,
- strokeWidth: 0.4,
- dashArray: [8, 4],
- );
-}
+FlLine defaultGridLine(double value) => const FlLine(
+ color: Colors.blueGrey,
+ strokeWidth: 0.4,
+ dashArray: [8, 4],
+ );
/// Defines style of a line.
class FlLine with EquatableMixin {
@@ -719,14 +704,12 @@ class FlLine with EquatableMixin {
final List? dashArray;
/// Lerps a [FlLine] based on [t] value, check [Tween.lerp].
- static FlLine lerp(FlLine a, FlLine b, double t) {
- return FlLine(
- color: Color.lerp(a.color, b.color, t),
- gradient: Gradient.lerp(a.gradient, b.gradient, t),
- strokeWidth: lerpDouble(a.strokeWidth, b.strokeWidth, t)!,
- dashArray: lerpIntList(a.dashArray, b.dashArray, t),
- );
- }
+ static FlLine lerp(FlLine a, FlLine b, double t) => FlLine(
+ color: Color.lerp(a.color, b.color, t),
+ gradient: Gradient.lerp(a.gradient, b.gradient, t),
+ strokeWidth: lerpDouble(a.strokeWidth, b.strokeWidth, t)!,
+ dashArray: lerpIntList(a.dashArray, b.dashArray, t),
+ );
/// Copies current [FlLine] to a new [FlLine],
/// and replaces provided values.
@@ -735,14 +718,13 @@ class FlLine with EquatableMixin {
Gradient? gradient,
double? strokeWidth,
List? dashArray,
- }) {
- return FlLine(
- color: color ?? this.color,
- gradient: gradient ?? this.gradient,
- strokeWidth: strokeWidth ?? this.strokeWidth,
- dashArray: dashArray ?? this.dashArray,
- );
- }
+ }) =>
+ FlLine(
+ color: color ?? this.color,
+ gradient: gradient ?? this.gradient,
+ strokeWidth: strokeWidth ?? this.strokeWidth,
+ dashArray: dashArray ?? this.dashArray,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -799,34 +781,32 @@ class RangeAnnotations with EquatableMixin {
RangeAnnotations a,
RangeAnnotations b,
double t,
- ) {
- return RangeAnnotations(
- horizontalRangeAnnotations: lerpHorizontalRangeAnnotationList(
- a.horizontalRangeAnnotations,
- b.horizontalRangeAnnotations,
- t,
- )!,
- verticalRangeAnnotations: lerpVerticalRangeAnnotationList(
- a.verticalRangeAnnotations,
- b.verticalRangeAnnotations,
- t,
- )!,
- );
- }
+ ) =>
+ RangeAnnotations(
+ horizontalRangeAnnotations: lerpHorizontalRangeAnnotationList(
+ a.horizontalRangeAnnotations,
+ b.horizontalRangeAnnotations,
+ t,
+ )!,
+ verticalRangeAnnotations: lerpVerticalRangeAnnotationList(
+ a.verticalRangeAnnotations,
+ b.verticalRangeAnnotations,
+ t,
+ )!,
+ );
/// Copies current [RangeAnnotations] to a new [RangeAnnotations],
/// and replaces provided values.
RangeAnnotations copyWith({
List? horizontalRangeAnnotations,
List? verticalRangeAnnotations,
- }) {
- return RangeAnnotations(
- horizontalRangeAnnotations:
- horizontalRangeAnnotations ?? this.horizontalRangeAnnotations,
- verticalRangeAnnotations:
- verticalRangeAnnotations ?? this.verticalRangeAnnotations,
- );
- }
+ }) =>
+ RangeAnnotations(
+ horizontalRangeAnnotations:
+ horizontalRangeAnnotations ?? this.horizontalRangeAnnotations,
+ verticalRangeAnnotations:
+ verticalRangeAnnotations ?? this.verticalRangeAnnotations,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -871,14 +851,13 @@ class HorizontalRangeAnnotation with EquatableMixin {
HorizontalRangeAnnotation a,
HorizontalRangeAnnotation b,
double t,
- ) {
- return HorizontalRangeAnnotation(
- y1: lerpDouble(a.y1, b.y1, t)!,
- y2: lerpDouble(a.y2, b.y2, t)!,
- color: Color.lerp(a.color, b.color, t),
- gradient: Gradient.lerp(a.gradient, b.gradient, t),
- );
- }
+ ) =>
+ HorizontalRangeAnnotation(
+ y1: lerpDouble(a.y1, b.y1, t)!,
+ y2: lerpDouble(a.y2, b.y2, t)!,
+ color: Color.lerp(a.color, b.color, t),
+ gradient: Gradient.lerp(a.gradient, b.gradient, t),
+ );
/// Copies current [HorizontalRangeAnnotation] to a new [HorizontalRangeAnnotation],
/// and replaces provided values.
@@ -887,14 +866,13 @@ class HorizontalRangeAnnotation with EquatableMixin {
double? y2,
Color? color,
Gradient? gradient,
- }) {
- return HorizontalRangeAnnotation(
- y1: y1 ?? this.y1,
- y2: y2 ?? this.y2,
- color: color ?? this.color,
- gradient: gradient ?? this.gradient,
- );
- }
+ }) =>
+ HorizontalRangeAnnotation(
+ y1: y1 ?? this.y1,
+ y2: y2 ?? this.y2,
+ color: color ?? this.color,
+ gradient: gradient ?? this.gradient,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -941,14 +919,13 @@ class VerticalRangeAnnotation with EquatableMixin {
VerticalRangeAnnotation a,
VerticalRangeAnnotation b,
double t,
- ) {
- return VerticalRangeAnnotation(
- x1: lerpDouble(a.x1, b.x1, t)!,
- x2: lerpDouble(a.x2, b.x2, t)!,
- color: Color.lerp(a.color, b.color, t),
- gradient: Gradient.lerp(a.gradient, b.gradient, t),
- );
- }
+ ) =>
+ VerticalRangeAnnotation(
+ x1: lerpDouble(a.x1, b.x1, t)!,
+ x2: lerpDouble(a.x2, b.x2, t)!,
+ color: Color.lerp(a.color, b.color, t),
+ gradient: Gradient.lerp(a.gradient, b.gradient, t),
+ );
/// Copies current [VerticalRangeAnnotation] to a new [VerticalRangeAnnotation],
/// and replaces provided values.
@@ -957,14 +934,13 @@ class VerticalRangeAnnotation with EquatableMixin {
double? x2,
Color? color,
Gradient? gradient,
- }) {
- return VerticalRangeAnnotation(
- x1: x1 ?? this.x1,
- x2: x2 ?? this.x2,
- color: color ?? this.color,
- gradient: gradient ?? this.gradient,
- );
- }
+ }) =>
+ VerticalRangeAnnotation(
+ x1: x1 ?? this.x1,
+ x2: x2 ?? this.x2,
+ color: color ?? this.color,
+ gradient: gradient ?? this.gradient,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -1020,19 +996,18 @@ class HorizontalLine extends FlLine with EquatableMixin {
final StrokeCap strokeCap;
/// Lerps a [HorizontalLine] based on [t] value, check [Tween.lerp].
- static HorizontalLine lerp(HorizontalLine a, HorizontalLine b, double t) {
- return HorizontalLine(
- y: lerpDouble(a.y, b.y, t)!,
- label: HorizontalLineLabel.lerp(a.label, b.label, t),
- color: Color.lerp(a.color, b.color, t),
- gradient: Gradient.lerp(a.gradient, b.gradient, t),
- strokeWidth: lerpDouble(a.strokeWidth, b.strokeWidth, t)!,
- dashArray: lerpIntList(a.dashArray, b.dashArray, t),
- image: b.image,
- sizedPicture: b.sizedPicture,
- strokeCap: b.strokeCap,
- );
- }
+ static HorizontalLine lerp(HorizontalLine a, HorizontalLine b, double t) =>
+ HorizontalLine(
+ y: lerpDouble(a.y, b.y, t)!,
+ label: HorizontalLineLabel.lerp(a.label, b.label, t),
+ color: Color.lerp(a.color, b.color, t),
+ gradient: Gradient.lerp(a.gradient, b.gradient, t),
+ strokeWidth: lerpDouble(a.strokeWidth, b.strokeWidth, t)!,
+ dashArray: lerpIntList(a.dashArray, b.dashArray, t),
+ image: b.image,
+ sizedPicture: b.sizedPicture,
+ strokeCap: b.strokeCap,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -1092,19 +1067,18 @@ class VerticalLine extends FlLine with EquatableMixin {
final StrokeCap strokeCap;
/// Lerps a [VerticalLine] based on [t] value, check [Tween.lerp].
- static VerticalLine lerp(VerticalLine a, VerticalLine b, double t) {
- return VerticalLine(
- x: lerpDouble(a.x, b.x, t)!,
- label: VerticalLineLabel.lerp(a.label, b.label, t),
- color: Color.lerp(a.color, b.color, t),
- gradient: Gradient.lerp(a.gradient, b.gradient, t),
- strokeWidth: lerpDouble(a.strokeWidth, b.strokeWidth, t)!,
- dashArray: lerpIntList(a.dashArray, b.dashArray, t),
- image: b.image,
- sizedPicture: b.sizedPicture,
- strokeCap: b.strokeCap,
- );
- }
+ static VerticalLine lerp(VerticalLine a, VerticalLine b, double t) =>
+ VerticalLine(
+ x: lerpDouble(a.x, b.x, t)!,
+ label: VerticalLineLabel.lerp(a.label, b.label, t),
+ color: Color.lerp(a.color, b.color, t),
+ gradient: Gradient.lerp(a.gradient, b.gradient, t),
+ strokeWidth: lerpDouble(a.strokeWidth, b.strokeWidth, t)!,
+ dashArray: lerpIntList(a.dashArray, b.dashArray, t),
+ image: b.image,
+ sizedPicture: b.sizedPicture,
+ strokeCap: b.strokeCap,
+ );
/// Copies current [VerticalLine] to a new [VerticalLine]
/// and replaces provided values.
@@ -1117,18 +1091,17 @@ class VerticalLine extends FlLine with EquatableMixin {
Image? image,
SizedPicture? sizedPicture,
StrokeCap? strokeCap,
- }) {
- return VerticalLine(
- x: x ?? this.x,
- label: label ?? this.label,
- color: color ?? this.color,
- strokeWidth: strokeWidth ?? this.strokeWidth,
- dashArray: dashArray ?? this.dashArray,
- image: image ?? this.image,
- sizedPicture: sizedPicture ?? this.sizedPicture,
- strokeCap: strokeCap ?? this.strokeCap,
- );
- }
+ }) =>
+ VerticalLine(
+ x: x ?? this.x,
+ label: label ?? this.label,
+ color: color ?? this.color,
+ strokeWidth: strokeWidth ?? this.strokeWidth,
+ dashArray: dashArray ?? this.dashArray,
+ image: image ?? this.image,
+ sizedPicture: sizedPicture ?? this.sizedPicture,
+ strokeCap: strokeCap ?? this.strokeCap,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -1174,17 +1147,19 @@ class HorizontalLineLabel extends FlLineLabel with EquatableMixin {
HorizontalLineLabel a,
HorizontalLineLabel b,
double t,
- ) {
- return HorizontalLineLabel(
- padding:
- EdgeInsets.lerp(a.padding as EdgeInsets, b.padding as EdgeInsets, t)!,
- style: TextStyle.lerp(a.style, b.style, t),
- alignment: Alignment.lerp(a.alignment, b.alignment, t)!,
- labelResolver: b.labelResolver,
- show: b.show,
- direction: b.direction,
- );
- }
+ ) =>
+ HorizontalLineLabel(
+ padding: EdgeInsets.lerp(
+ a.padding as EdgeInsets,
+ b.padding as EdgeInsets,
+ t,
+ )!,
+ style: TextStyle.lerp(a.style, b.style, t),
+ alignment: Alignment.lerp(a.alignment, b.alignment, t)!,
+ labelResolver: b.labelResolver,
+ show: b.show,
+ direction: b.direction,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -1232,17 +1207,19 @@ class VerticalLineLabel extends FlLineLabel with EquatableMixin {
VerticalLineLabel a,
VerticalLineLabel b,
double t,
- ) {
- return VerticalLineLabel(
- padding:
- EdgeInsets.lerp(a.padding as EdgeInsets, b.padding as EdgeInsets, t)!,
- style: TextStyle.lerp(a.style, b.style, t),
- alignment: Alignment.lerp(a.alignment, b.alignment, t)!,
- labelResolver: b.labelResolver,
- show: b.show,
- direction: b.direction,
- );
- }
+ ) =>
+ VerticalLineLabel(
+ padding: EdgeInsets.lerp(
+ a.padding as EdgeInsets,
+ b.padding as EdgeInsets,
+ t,
+ )!,
+ style: TextStyle.lerp(a.style, b.style, t),
+ alignment: Alignment.lerp(a.alignment, b.alignment, t)!,
+ labelResolver: b.labelResolver,
+ show: b.show,
+ direction: b.direction,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -1317,14 +1294,14 @@ class ExtraLinesData with EquatableMixin {
final bool extraLinesOnTop;
/// Lerps a [ExtraLinesData] based on [t] value, check [Tween.lerp].
- static ExtraLinesData lerp(ExtraLinesData a, ExtraLinesData b, double t) {
- return ExtraLinesData(
- extraLinesOnTop: b.extraLinesOnTop,
- horizontalLines:
- lerpHorizontalLineList(a.horizontalLines, b.horizontalLines, t)!,
- verticalLines: lerpVerticalLineList(a.verticalLines, b.verticalLines, t)!,
- );
- }
+ static ExtraLinesData lerp(ExtraLinesData a, ExtraLinesData b, double t) =>
+ ExtraLinesData(
+ extraLinesOnTop: b.extraLinesOnTop,
+ horizontalLines:
+ lerpHorizontalLineList(a.horizontalLines, b.horizontalLines, t)!,
+ verticalLines:
+ lerpVerticalLineList(a.verticalLines, b.verticalLines, t)!,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -1421,9 +1398,7 @@ class FlDotCirclePainter extends FlDotPainter {
/// Implementation of the parent class to get the size of the circle
@override
- Size getSize(FlSpot spot) {
- return Size(radius * 2, radius * 2);
- }
+ Size getSize(FlSpot spot) => Size(radius * 2, radius * 2);
@override
Color get mainColor => color;
@@ -1432,14 +1407,13 @@ class FlDotCirclePainter extends FlDotPainter {
FlDotCirclePainter a,
FlDotCirclePainter b,
double t,
- ) {
- return FlDotCirclePainter(
- color: Color.lerp(a.color, b.color, t)!,
- radius: lerpDouble(a.radius, b.radius, t),
- strokeColor: Color.lerp(a.strokeColor, b.strokeColor, t)!,
- strokeWidth: lerpDouble(a.strokeWidth, b.strokeWidth, t)!,
- );
- }
+ ) =>
+ FlDotCirclePainter(
+ color: Color.lerp(a.color, b.color, t)!,
+ radius: lerpDouble(a.radius, b.radius, t),
+ strokeColor: Color.lerp(a.strokeColor, b.strokeColor, t)!,
+ strokeWidth: lerpDouble(a.strokeWidth, b.strokeWidth, t)!,
+ );
@override
FlDotPainter lerp(FlDotPainter a, FlDotPainter b, double t) {
@@ -1525,9 +1499,7 @@ class FlDotSquarePainter extends FlDotPainter {
/// Implementation of the parent class to get the size of the square
@override
- Size getSize(FlSpot spot) {
- return Size(size, size);
- }
+ Size getSize(FlSpot spot) => Size(size, size);
@override
Color get mainColor => color;
@@ -1545,14 +1517,13 @@ class FlDotSquarePainter extends FlDotPainter {
FlDotSquarePainter a,
FlDotSquarePainter b,
double t,
- ) {
- return FlDotSquarePainter(
- color: Color.lerp(a.color, b.color, t)!,
- size: lerpDouble(a.size, b.size, t)!,
- strokeColor: Color.lerp(a.strokeColor, b.strokeColor, t)!,
- strokeWidth: lerpDouble(a.strokeWidth, b.strokeWidth, t)!,
- );
- }
+ ) =>
+ FlDotSquarePainter(
+ color: Color.lerp(a.color, b.color, t)!,
+ size: lerpDouble(a.size, b.size, t)!,
+ strokeColor: Color.lerp(a.strokeColor, b.strokeColor, t)!,
+ strokeWidth: lerpDouble(a.strokeWidth, b.strokeWidth, t)!,
+ );
@override
FlDotPainter lerp(FlDotPainter a, FlDotPainter b, double t) {
@@ -1604,9 +1575,7 @@ class FlDotCrossPainter extends FlDotPainter {
/// Implementation of the parent class to get the size of the circle
@override
- Size getSize(FlSpot spot) {
- return Size(size, size);
- }
+ Size getSize(FlSpot spot) => Size(size, size);
@override
Color get mainColor => color;
@@ -1615,13 +1584,12 @@ class FlDotCrossPainter extends FlDotPainter {
FlDotCrossPainter a,
FlDotCrossPainter b,
double t,
- ) {
- return FlDotCrossPainter(
- color: Color.lerp(a.color, b.color, t)!,
- size: lerpDouble(a.size, b.size, t)!,
- width: lerpDouble(a.width, b.width, t)!,
- );
- }
+ ) =>
+ FlDotCrossPainter(
+ color: Color.lerp(a.color, b.color, t)!,
+ size: lerpDouble(a.size, b.size, t)!,
+ width: lerpDouble(a.width, b.width, t)!,
+ );
@override
FlDotPainter lerp(FlDotPainter a, FlDotPainter b, double t) {
diff --git a/lib/src/chart/base/axis_chart/axis_chart_helper.dart b/lib/src/chart/base/axis_chart/axis_chart_helper.dart
index b287b6730..d9179fb40 100644
--- a/lib/src/chart/base/axis_chart/axis_chart_helper.dart
+++ b/lib/src/chart/base/axis_chart/axis_chart_helper.dart
@@ -8,6 +8,7 @@ class AxisChartHelper {
}
AxisChartHelper._internal();
+
static final _singleton = AxisChartHelper._internal();
/// Iterates over an axis from [min] to [max].
@@ -32,7 +33,7 @@ class AxisChartHelper {
var axisSeek = initialValue;
final firstPositionOverlapsWithMin = axisSeek == min;
if (!minIncluded && firstPositionOverlapsWithMin) {
- // If inital value is equal to data minimum,
+ // If initial value is equal to data minimum,
// move first label one interval further
axisSeek += interval;
}
@@ -95,13 +96,9 @@ class AxisChartHelper {
-(childSize / 2) + (parentAxisSize - axisPosition) - distanceFromEdge;
}
- switch (axisSide) {
- case AxisSide.left:
- case AxisSide.right:
- return Offset(0, offset);
- case AxisSide.top:
- case AxisSide.bottom:
- return Offset(offset, 0);
- }
+ return switch (axisSide) {
+ AxisSide.left || AxisSide.right => Offset(0, offset),
+ AxisSide.top || AxisSide.bottom => Offset(offset, 0),
+ };
}
}
diff --git a/lib/src/chart/base/axis_chart/axis_chart_painter.dart b/lib/src/chart/base/axis_chart/axis_chart_painter.dart
index 3b0ff7f03..4954a90fa 100644
--- a/lib/src/chart/base/axis_chart/axis_chart_painter.dart
+++ b/lib/src/chart/base/axis_chart/axis_chart_painter.dart
@@ -26,6 +26,7 @@ abstract class AxisChartPainter
_imagePaint = Paint();
}
+
late Paint _gridPaint;
late Paint _backgroundPaint;
late Paint _extraLinesPaint;
@@ -474,14 +475,12 @@ abstract class AxisChartPainter
double tooltipWidth,
FLHorizontalAlignment tooltipHorizontalAlignment,
double tooltipHorizontalOffset,
- ) {
- switch (tooltipHorizontalAlignment) {
- case FLHorizontalAlignment.center:
- return dx - (tooltipWidth / 2) + tooltipHorizontalOffset;
- case FLHorizontalAlignment.right:
- return dx + tooltipHorizontalOffset;
- case FLHorizontalAlignment.left:
- return dx - tooltipWidth + tooltipHorizontalOffset;
- }
- }
+ ) =>
+ switch (tooltipHorizontalAlignment) {
+ FLHorizontalAlignment.center =>
+ dx - (tooltipWidth / 2) + tooltipHorizontalOffset,
+ FLHorizontalAlignment.right => dx + tooltipHorizontalOffset,
+ FLHorizontalAlignment.left =>
+ dx - tooltipWidth + tooltipHorizontalOffset,
+ };
}
diff --git a/lib/src/chart/base/axis_chart/axis_chart_widgets.dart b/lib/src/chart/base/axis_chart/axis_chart_widgets.dart
index c3e1788e0..b9a010b78 100644
--- a/lib/src/chart/base/axis_chart/axis_chart_widgets.dart
+++ b/lib/src/chart/base/axis_chart/axis_chart_widgets.dart
@@ -53,35 +53,24 @@ class SideTitleWidget extends StatefulWidget {
}
class _SideTitleWidgetState extends State {
- Alignment _getAlignment() {
- switch (widget.axisSide) {
- case AxisSide.left:
- return Alignment.centerRight;
- case AxisSide.top:
- return Alignment.bottomCenter;
- case AxisSide.right:
- return Alignment.centerLeft;
- case AxisSide.bottom:
- return Alignment.topCenter;
- }
- }
+ Alignment _getAlignment() => switch (widget.axisSide) {
+ AxisSide.left => Alignment.centerRight,
+ AxisSide.top => Alignment.bottomCenter,
+ AxisSide.right => Alignment.centerLeft,
+ AxisSide.bottom => Alignment.topCenter,
+ };
- EdgeInsets _getMargin() {
- switch (widget.axisSide) {
- case AxisSide.left:
- return EdgeInsets.only(right: widget.space);
- case AxisSide.top:
- return EdgeInsets.only(bottom: widget.space);
- case AxisSide.right:
- return EdgeInsets.only(left: widget.space);
- case AxisSide.bottom:
- return EdgeInsets.only(top: widget.space);
- }
- }
+ EdgeInsets _getMargin() => switch (widget.axisSide) {
+ AxisSide.left => EdgeInsets.only(right: widget.space),
+ AxisSide.top => EdgeInsets.only(bottom: widget.space),
+ AxisSide.right => EdgeInsets.only(left: widget.space),
+ AxisSide.bottom => EdgeInsets.only(top: widget.space),
+ };
/// Calculate child width/height
final GlobalKey widgetKey = GlobalKey();
double? _childSize;
+
void _getChildSize(_) {
// If fitInside is false, no need to find child size
if (!widget.fitInside.enabled) return;
diff --git a/lib/src/chart/base/axis_chart/side_titles/side_titles_widget.dart b/lib/src/chart/base/axis_chart/side_titles/side_titles_widget.dart
index c1363b39a..da6d00915 100644
--- a/lib/src/chart/base/axis_chart/side_titles/side_titles_widget.dart
+++ b/lib/src/chart/base/axis_chart/side_titles/side_titles_widget.dart
@@ -15,6 +15,7 @@ class SideTitlesWidget extends StatelessWidget {
required this.axisChartData,
required this.parentSize,
});
+
final AxisSide side;
final AxisChartData axisChartData;
final Size parentSize;
@@ -47,18 +48,12 @@ class SideTitlesWidget extends StatelessWidget {
bool get isRightOrBottom => side == AxisSide.right || side == AxisSide.bottom;
- AxisTitles get axisTitles {
- switch (side) {
- case AxisSide.left:
- return titlesData.leftTitles;
- case AxisSide.top:
- return titlesData.topTitles;
- case AxisSide.right:
- return titlesData.rightTitles;
- case AxisSide.bottom:
- return titlesData.bottomTitles;
- }
- }
+ AxisTitles get axisTitles => switch (side) {
+ AxisSide.left => titlesData.leftTitles,
+ AxisSide.top => titlesData.topTitles,
+ AxisSide.right => titlesData.rightTitles,
+ AxisSide.bottom => titlesData.bottomTitles,
+ };
SideTitles get sideTitles => axisTitles.sideTitles;
@@ -66,43 +61,37 @@ class SideTitlesWidget extends StatelessWidget {
Axis get counterDirection => isHorizontal ? Axis.vertical : Axis.horizontal;
- Alignment get alignment {
- switch (side) {
- case AxisSide.left:
- return Alignment.centerLeft;
- case AxisSide.top:
- return Alignment.topCenter;
- case AxisSide.right:
- return Alignment.centerRight;
- case AxisSide.bottom:
- return Alignment.bottomCenter;
- }
- }
+ Alignment get alignment => switch (side) {
+ AxisSide.left => Alignment.centerLeft,
+ AxisSide.top => Alignment.topCenter,
+ AxisSide.right => Alignment.centerRight,
+ AxisSide.bottom => Alignment.bottomCenter,
+ };
EdgeInsets get thisSidePadding {
final titlesPadding = titlesData.allSidesPadding;
final borderPadding = axisChartData.borderData.allSidesPadding;
- switch (side) {
- case AxisSide.right:
- case AxisSide.left:
- return titlesPadding.onlyTopBottom + borderPadding.onlyTopBottom;
- case AxisSide.top:
- case AxisSide.bottom:
- return titlesPadding.onlyLeftRight + borderPadding.onlyLeftRight;
- }
+ return switch (side) {
+ AxisSide.right ||
+ AxisSide.left =>
+ titlesPadding.onlyTopBottom + borderPadding.onlyTopBottom,
+ AxisSide.top ||
+ AxisSide.bottom =>
+ titlesPadding.onlyLeftRight + borderPadding.onlyLeftRight,
+ };
}
double get thisSidePaddingTotal {
final borderPadding = axisChartData.borderData.allSidesPadding;
final titlesPadding = titlesData.allSidesPadding;
- switch (side) {
- case AxisSide.right:
- case AxisSide.left:
- return titlesPadding.vertical + borderPadding.vertical;
- case AxisSide.top:
- case AxisSide.bottom:
- return titlesPadding.horizontal + borderPadding.horizontal;
- }
+ return switch (side) {
+ AxisSide.right ||
+ AxisSide.left =>
+ titlesPadding.vertical + borderPadding.vertical,
+ AxisSide.top ||
+ AxisSide.bottom =>
+ titlesPadding.horizontal + borderPadding.horizontal,
+ };
}
List makeWidgets(
@@ -233,22 +222,17 @@ class _AxisTitleWidget extends StatelessWidget {
required this.side,
required this.axisViewSize,
});
+
final AxisTitles axisTitles;
final AxisSide side;
final double axisViewSize;
- int get axisNameQuarterTurns {
- switch (side) {
- case AxisSide.right:
- return 3;
- case AxisSide.left:
- return 3;
- case AxisSide.top:
- return 0;
- case AxisSide.bottom:
- return 0;
- }
- }
+ int get axisNameQuarterTurns => switch (side) {
+ AxisSide.right => 3,
+ AxisSide.left => 3,
+ AxisSide.top => 0,
+ AxisSide.bottom => 0,
+ };
bool get isHorizontal => side == AxisSide.top || side == AxisSide.bottom;
diff --git a/lib/src/chart/base/base_chart/base_chart_data.dart b/lib/src/chart/base/base_chart/base_chart_data.dart
index 5bcc39d84..3b4ad58f8 100644
--- a/lib/src/chart/base/base_chart/base_chart_data.dart
+++ b/lib/src/chart/base/base_chart/base_chart_data.dart
@@ -51,24 +51,22 @@ class FlBorderData with EquatableMixin {
bool isVisible() => show && border.isVisible();
/// Lerps a [FlBorderData] based on [t] value, check [Tween.lerp].
- static FlBorderData lerp(FlBorderData a, FlBorderData b, double t) {
- return FlBorderData(
- show: b.show,
- border: Border.lerp(a.border, b.border, t),
- );
- }
+ static FlBorderData lerp(FlBorderData a, FlBorderData b, double t) =>
+ FlBorderData(
+ show: b.show,
+ border: Border.lerp(a.border, b.border, t),
+ );
/// Copies current [FlBorderData] to a new [FlBorderData],
/// and replaces provided values.
FlBorderData copyWith({
bool? show,
Border? border,
- }) {
- return FlBorderData(
- show: show ?? this.show,
- border: border ?? this.border,
- );
- }
+ }) =>
+ FlBorderData(
+ show: show ?? this.show,
+ border: border ?? this.border,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -160,14 +158,13 @@ class FlClipData with EquatableMixin {
bool? bottom,
bool? left,
bool? right,
- }) {
- return FlClipData(
- top: top ?? this.top,
- bottom: bottom ?? this.bottom,
- left: left ?? this.left,
- right: right ?? this.right,
- );
- }
+ }) =>
+ FlClipData(
+ top: top ?? this.top,
+ bottom: bottom ?? this.bottom,
+ left: left ?? this.left,
+ right: right ?? this.right,
+ );
/// Used for equality check, see [EquatableMixin].
@override
diff --git a/lib/src/chart/line_chart/line_chart_data.dart b/lib/src/chart/line_chart/line_chart_data.dart
index 02ffb9eb7..0ff55b30f 100644
--- a/lib/src/chart/line_chart/line_chart_data.dart
+++ b/lib/src/chart/line_chart/line_chart_data.dart
@@ -135,28 +135,27 @@ class LineChartData extends AxisChartData with EquatableMixin {
double? baselineY,
FlClipData? clipData,
Color? backgroundColor,
- }) {
- return LineChartData(
- lineBarsData: lineBarsData ?? this.lineBarsData,
- betweenBarsData: betweenBarsData ?? this.betweenBarsData,
- titlesData: titlesData ?? this.titlesData,
- rangeAnnotations: rangeAnnotations ?? this.rangeAnnotations,
- extraLinesData: extraLinesData ?? this.extraLinesData,
- lineTouchData: lineTouchData ?? this.lineTouchData,
- showingTooltipIndicators:
- showingTooltipIndicators ?? this.showingTooltipIndicators,
- gridData: gridData ?? this.gridData,
- borderData: borderData ?? this.borderData,
- minX: minX ?? this.minX,
- maxX: maxX ?? this.maxX,
- baselineX: baselineX ?? this.baselineX,
- minY: minY ?? this.minY,
- maxY: maxY ?? this.maxY,
- baselineY: baselineY ?? this.baselineY,
- clipData: clipData ?? this.clipData,
- backgroundColor: backgroundColor ?? this.backgroundColor,
- );
- }
+ }) =>
+ LineChartData(
+ lineBarsData: lineBarsData ?? this.lineBarsData,
+ betweenBarsData: betweenBarsData ?? this.betweenBarsData,
+ titlesData: titlesData ?? this.titlesData,
+ rangeAnnotations: rangeAnnotations ?? this.rangeAnnotations,
+ extraLinesData: extraLinesData ?? this.extraLinesData,
+ lineTouchData: lineTouchData ?? this.lineTouchData,
+ showingTooltipIndicators:
+ showingTooltipIndicators ?? this.showingTooltipIndicators,
+ gridData: gridData ?? this.gridData,
+ borderData: borderData ?? this.borderData,
+ minX: minX ?? this.minX,
+ maxX: maxX ?? this.maxX,
+ baselineX: baselineX ?? this.baselineX,
+ minY: minY ?? this.minY,
+ maxY: maxY ?? this.maxY,
+ baselineY: baselineY ?? this.baselineY,
+ clipData: clipData ?? this.clipData,
+ backgroundColor: backgroundColor ?? this.backgroundColor,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -371,34 +370,33 @@ class LineChartBarData with EquatableMixin {
LineChartBarData a,
LineChartBarData b,
double t,
- ) {
- return LineChartBarData(
- show: b.show,
- barWidth: lerpDouble(a.barWidth, b.barWidth, t)!,
- belowBarData: BarAreaData.lerp(a.belowBarData, b.belowBarData, t),
- aboveBarData: BarAreaData.lerp(a.aboveBarData, b.aboveBarData, t),
- curveSmoothness: b.curveSmoothness,
- isCurved: b.isCurved,
- isStrokeCapRound: b.isStrokeCapRound,
- isStrokeJoinRound: b.isStrokeJoinRound,
- preventCurveOverShooting: b.preventCurveOverShooting,
- preventCurveOvershootingThreshold: lerpDouble(
- a.preventCurveOvershootingThreshold,
- b.preventCurveOvershootingThreshold,
- t,
- )!,
- dotData: FlDotData.lerp(a.dotData, b.dotData, t),
- dashArray: lerpIntList(a.dashArray, b.dashArray, t),
- color: Color.lerp(a.color, b.color, t),
- gradient: Gradient.lerp(a.gradient, b.gradient, t),
- spots: lerpFlSpotList(a.spots, b.spots, t)!,
- showingIndicators: b.showingIndicators,
- shadow: Shadow.lerp(a.shadow, b.shadow, t)!,
- isStepLineChart: b.isStepLineChart,
- lineChartStepData:
- LineChartStepData.lerp(a.lineChartStepData, b.lineChartStepData, t),
- );
- }
+ ) =>
+ LineChartBarData(
+ show: b.show,
+ barWidth: lerpDouble(a.barWidth, b.barWidth, t)!,
+ belowBarData: BarAreaData.lerp(a.belowBarData, b.belowBarData, t),
+ aboveBarData: BarAreaData.lerp(a.aboveBarData, b.aboveBarData, t),
+ curveSmoothness: b.curveSmoothness,
+ isCurved: b.isCurved,
+ isStrokeCapRound: b.isStrokeCapRound,
+ isStrokeJoinRound: b.isStrokeJoinRound,
+ preventCurveOverShooting: b.preventCurveOverShooting,
+ preventCurveOvershootingThreshold: lerpDouble(
+ a.preventCurveOvershootingThreshold,
+ b.preventCurveOvershootingThreshold,
+ t,
+ )!,
+ dotData: FlDotData.lerp(a.dotData, b.dotData, t),
+ dashArray: lerpIntList(a.dashArray, b.dashArray, t),
+ color: Color.lerp(a.color, b.color, t),
+ gradient: Gradient.lerp(a.gradient, b.gradient, t),
+ spots: lerpFlSpotList(a.spots, b.spots, t)!,
+ showingIndicators: b.showingIndicators,
+ shadow: Shadow.lerp(a.shadow, b.shadow, t)!,
+ isStepLineChart: b.isStepLineChart,
+ lineChartStepData:
+ LineChartStepData.lerp(a.lineChartStepData, b.lineChartStepData, t),
+ );
/// Copies current [LineChartBarData] to a new [LineChartBarData],
/// and replaces provided values.
@@ -422,31 +420,30 @@ class LineChartBarData with EquatableMixin {
Shadow? shadow,
bool? isStepLineChart,
LineChartStepData? lineChartStepData,
- }) {
- return LineChartBarData(
- spots: spots ?? this.spots,
- show: show ?? this.show,
- color: color ?? this.color,
- gradient: gradient ?? this.gradient,
- barWidth: barWidth ?? this.barWidth,
- isCurved: isCurved ?? this.isCurved,
- curveSmoothness: curveSmoothness ?? this.curveSmoothness,
- preventCurveOverShooting:
- preventCurveOverShooting ?? this.preventCurveOverShooting,
- preventCurveOvershootingThreshold: preventCurveOvershootingThreshold ??
- this.preventCurveOvershootingThreshold,
- isStrokeCapRound: isStrokeCapRound ?? this.isStrokeCapRound,
- isStrokeJoinRound: isStrokeJoinRound ?? this.isStrokeJoinRound,
- belowBarData: belowBarData ?? this.belowBarData,
- aboveBarData: aboveBarData ?? this.aboveBarData,
- dashArray: dashArray ?? this.dashArray,
- dotData: dotData ?? this.dotData,
- showingIndicators: showingIndicators ?? this.showingIndicators,
- shadow: shadow ?? this.shadow,
- isStepLineChart: isStepLineChart ?? this.isStepLineChart,
- lineChartStepData: lineChartStepData ?? this.lineChartStepData,
- );
- }
+ }) =>
+ LineChartBarData(
+ spots: spots ?? this.spots,
+ show: show ?? this.show,
+ color: color ?? this.color,
+ gradient: gradient ?? this.gradient,
+ barWidth: barWidth ?? this.barWidth,
+ isCurved: isCurved ?? this.isCurved,
+ curveSmoothness: curveSmoothness ?? this.curveSmoothness,
+ preventCurveOverShooting:
+ preventCurveOverShooting ?? this.preventCurveOverShooting,
+ preventCurveOvershootingThreshold: preventCurveOvershootingThreshold ??
+ this.preventCurveOvershootingThreshold,
+ isStrokeCapRound: isStrokeCapRound ?? this.isStrokeCapRound,
+ isStrokeJoinRound: isStrokeJoinRound ?? this.isStrokeJoinRound,
+ belowBarData: belowBarData ?? this.belowBarData,
+ aboveBarData: aboveBarData ?? this.aboveBarData,
+ dashArray: dashArray ?? this.dashArray,
+ dotData: dotData ?? this.dotData,
+ showingIndicators: showingIndicators ?? this.showingIndicators,
+ shadow: shadow ?? this.shadow,
+ isStepLineChart: isStepLineChart ?? this.isStepLineChart,
+ lineChartStepData: lineChartStepData ?? this.lineChartStepData,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -495,11 +492,10 @@ class LineChartStepData with EquatableMixin {
LineChartStepData a,
LineChartStepData b,
double t,
- ) {
- return LineChartStepData(
- stepDirection: lerpDouble(a.stepDirection, b.stepDirection, t)!,
- );
- }
+ ) =>
+ LineChartStepData(
+ stepDirection: lerpDouble(a.stepDirection, b.stepDirection, t)!,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -556,17 +552,16 @@ class BarAreaData with EquatableMixin {
final bool applyCutOffY;
/// Lerps a [BarAreaData] based on [t] value, check [Tween.lerp].
- static BarAreaData lerp(BarAreaData a, BarAreaData b, double t) {
- return BarAreaData(
- show: b.show,
- spotsLine: BarAreaSpotsLine.lerp(a.spotsLine, b.spotsLine, t),
- color: Color.lerp(a.color, b.color, t),
- // ignore: invalid_use_of_protected_member
- gradient: Gradient.lerp(a.gradient, b.gradient, t),
- cutOffY: lerpDouble(a.cutOffY, b.cutOffY, t)!,
- applyCutOffY: b.applyCutOffY,
- );
- }
+ static BarAreaData lerp(BarAreaData a, BarAreaData b, double t) =>
+ BarAreaData(
+ show: b.show,
+ spotsLine: BarAreaSpotsLine.lerp(a.spotsLine, b.spotsLine, t),
+ color: Color.lerp(a.color, b.color, t),
+ // ignore: invalid_use_of_protected_member
+ gradient: Gradient.lerp(a.gradient, b.gradient, t),
+ cutOffY: lerpDouble(a.cutOffY, b.cutOffY, t)!,
+ applyCutOffY: b.applyCutOffY,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -657,14 +652,13 @@ class BarAreaSpotsLine with EquatableMixin {
BarAreaSpotsLine a,
BarAreaSpotsLine b,
double t,
- ) {
- return BarAreaSpotsLine(
- show: b.show,
- checkToShowSpotLine: b.checkToShowSpotLine,
- flLineStyle: FlLine.lerp(a.flLineStyle, b.flLineStyle, t),
- applyCutOffY: b.applyCutOffY,
- );
- }
+ ) =>
+ BarAreaSpotsLine(
+ show: b.show,
+ checkToShowSpotLine: b.checkToShowSpotLine,
+ flLineStyle: FlLine.lerp(a.flLineStyle, b.flLineStyle, t),
+ applyCutOffY: b.applyCutOffY,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -683,9 +677,7 @@ class BarAreaSpotsLine with EquatableMixin {
typedef CheckToShowSpotLine = bool Function(FlSpot spot);
/// Shows all spot lines.
-bool showAllSpotsBelowLine(FlSpot spot) {
- return true;
-}
+bool showAllSpotsBelowLine(FlSpot spot) => true;
/// The callback passed to get the color of a [FlSpot]
///
@@ -747,13 +739,12 @@ FlDotPainter _defaultGetDotPainter(
LineChartBarData bar,
int index, {
double? size,
-}) {
- return FlDotCirclePainter(
- radius: size,
- color: _defaultGetDotColor(spot, xPercentage, bar),
- strokeColor: _defaultGetDotStrokeColor(spot, xPercentage, bar),
- );
-}
+}) =>
+ FlDotCirclePainter(
+ radius: size,
+ color: _defaultGetDotColor(spot, xPercentage, bar),
+ strokeColor: _defaultGetDotStrokeColor(spot, xPercentage, bar),
+ );
/// This class holds data about drawing spot dots on the drawing bar line.
class FlDotData with EquatableMixin {
@@ -777,13 +768,11 @@ class FlDotData with EquatableMixin {
final GetDotPainterCallback getDotPainter;
/// Lerps a [FlDotData] based on [t] value, check [Tween.lerp].
- static FlDotData lerp(FlDotData a, FlDotData b, double t) {
- return FlDotData(
- show: b.show,
- checkToShowDot: b.checkToShowDot,
- getDotPainter: b.getDotPainter,
- );
- }
+ static FlDotData lerp(FlDotData a, FlDotData b, double t) => FlDotData(
+ show: b.show,
+ checkToShowDot: b.checkToShowDot,
+ getDotPainter: b.getDotPainter,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -801,9 +790,7 @@ class FlDotData with EquatableMixin {
typedef CheckToShowDot = bool Function(FlSpot spot, LineChartBarData barData);
/// Shows all dots on spots.
-bool showAllDots(FlSpot spot, LineChartBarData barData) {
- return true;
-}
+bool showAllDots(FlSpot spot, LineChartBarData barData) => true;
enum LabelDirection { horizontal, vertical }
@@ -928,22 +915,21 @@ class LineTouchData extends FlTouchData with EquatableMixin {
GetTouchLineY? getTouchLineStart,
GetTouchLineY? getTouchLineEnd,
bool? handleBuiltInTouches,
- }) {
- return LineTouchData(
- enabled: enabled ?? this.enabled,
- touchCallback: touchCallback ?? this.touchCallback,
- mouseCursorResolver: mouseCursorResolver ?? this.mouseCursorResolver,
- longPressDuration: longPressDuration ?? this.longPressDuration,
- touchTooltipData: touchTooltipData ?? this.touchTooltipData,
- getTouchedSpotIndicator:
- getTouchedSpotIndicator ?? this.getTouchedSpotIndicator,
- touchSpotThreshold: touchSpotThreshold ?? this.touchSpotThreshold,
- distanceCalculator: distanceCalculator ?? this.distanceCalculator,
- getTouchLineStart: getTouchLineStart ?? this.getTouchLineStart,
- getTouchLineEnd: getTouchLineEnd ?? this.getTouchLineEnd,
- handleBuiltInTouches: handleBuiltInTouches ?? this.handleBuiltInTouches,
- );
- }
+ }) =>
+ LineTouchData(
+ enabled: enabled ?? this.enabled,
+ touchCallback: touchCallback ?? this.touchCallback,
+ mouseCursorResolver: mouseCursorResolver ?? this.mouseCursorResolver,
+ longPressDuration: longPressDuration ?? this.longPressDuration,
+ touchTooltipData: touchTooltipData ?? this.touchTooltipData,
+ getTouchedSpotIndicator:
+ getTouchedSpotIndicator ?? this.getTouchedSpotIndicator,
+ touchSpotThreshold: touchSpotThreshold ?? this.touchSpotThreshold,
+ distanceCalculator: distanceCalculator ?? this.distanceCalculator,
+ getTouchLineStart: getTouchLineStart ?? this.getTouchLineStart,
+ getTouchLineEnd: getTouchLineEnd ?? this.getTouchLineEnd,
+ handleBuiltInTouches: handleBuiltInTouches ?? this.handleBuiltInTouches,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -986,37 +972,35 @@ typedef CalculateTouchDistance = double Function(
);
/// Default distanceCalculator only considers distance on x axis
-double _xDistance(Offset touchPoint, Offset spotPixelCoordinates) {
- return (touchPoint.dx - spotPixelCoordinates.dx).abs();
-}
+double _xDistance(Offset touchPoint, Offset spotPixelCoordinates) =>
+ (touchPoint.dx - spotPixelCoordinates.dx).abs();
/// Default presentation of touched indicators.
List defaultTouchedIndicators(
LineChartBarData barData,
List indicators,
-) {
- return indicators.map((int index) {
- /// Indicator Line
- var lineColor = barData.gradient?.colors.first ?? barData.color;
- if (barData.dotData.show) {
- lineColor = _defaultGetDotColor(barData.spots[index], 0, barData);
- }
- const lineStrokeWidth = 4.0;
- final flLine = FlLine(color: lineColor, strokeWidth: lineStrokeWidth);
+) =>
+ indicators.map((int index) {
+ /// Indicator Line
+ var lineColor = barData.gradient?.colors.first ?? barData.color;
+ if (barData.dotData.show) {
+ lineColor = _defaultGetDotColor(barData.spots[index], 0, barData);
+ }
+ const lineStrokeWidth = 4.0;
+ final flLine = FlLine(color: lineColor, strokeWidth: lineStrokeWidth);
- var dotSize = 10.0;
- if (barData.dotData.show) {
- dotSize = 4.0 * 1.8;
- }
+ var dotSize = 10.0;
+ if (barData.dotData.show) {
+ dotSize = 4.0 * 1.8;
+ }
- final dotData = FlDotData(
- getDotPainter: (spot, percent, bar, index) =>
- _defaultGetDotPainter(spot, percent, bar, index, size: dotSize),
- );
+ final dotData = FlDotData(
+ getDotPainter: (spot, percent, bar, index) =>
+ _defaultGetDotPainter(spot, percent, bar, index, size: dotSize),
+ );
- return TouchedSpotIndicatorData(flLine, dotData);
- }).toList();
-}
+ return TouchedSpotIndicatorData(flLine, dotData);
+ }).toList();
/// By default line starts from the bottom of the chart.
double defaultGetTouchLineStart(LineChartBarData barData, int spotIndex) {
@@ -1024,9 +1008,8 @@ double defaultGetTouchLineStart(LineChartBarData barData, int spotIndex) {
}
/// By default line ends at the touched point.
-double defaultGetTouchLineEnd(LineChartBarData barData, int spotIndex) {
- return barData.spots[spotIndex].y;
-}
+double defaultGetTouchLineEnd(LineChartBarData barData, int spotIndex) =>
+ barData.spots[spotIndex].y;
/// Holds representation data for showing tooltip popup on top of spots.
class LineTouchTooltipData with EquatableMixin {
@@ -1130,18 +1113,17 @@ typedef GetLineTooltipItems = List Function(
);
/// Default implementation for [LineTouchTooltipData.getTooltipItems].
-List defaultLineTooltipItem(List touchedSpots) {
- return touchedSpots.map((LineBarSpot touchedSpot) {
- final textStyle = TextStyle(
- color: touchedSpot.bar.gradient?.colors.first ??
- touchedSpot.bar.color ??
- Colors.blueGrey,
- fontWeight: FontWeight.bold,
- fontSize: 14,
- );
- return LineTooltipItem(touchedSpot.y.toString(), textStyle);
- }).toList();
-}
+List defaultLineTooltipItem(List touchedSpots) =>
+ touchedSpots.map((LineBarSpot touchedSpot) {
+ final textStyle = TextStyle(
+ color: touchedSpot.bar.gradient?.colors.first ??
+ touchedSpot.bar.color ??
+ Colors.blueGrey,
+ fontWeight: FontWeight.bold,
+ fontSize: 14,
+ );
+ return LineTooltipItem(touchedSpot.y.toString(), textStyle);
+ }).toList();
//// Provides a [Color] to show different background color for each touched spot
///
@@ -1154,9 +1136,8 @@ typedef GetLineTooltipColor = Color Function(
);
/// Default implementation for [LineTouchTooltipData.getTooltipColor].
-Color defaultLineTooltipColor(LineBarSpot touchedSpot) {
- return Colors.blueGrey.darken(15);
-}
+Color defaultLineTooltipColor(LineBarSpot touchedSpot) =>
+ Colors.blueGrey.darken(15);
/// Represent a targeted spot inside a line bar.
class LineBarSpot extends FlSpot with EquatableMixin {
@@ -1302,11 +1283,10 @@ class LineTouchResponse extends BaseTouchResponse {
/// and replaces provided values.
LineTouchResponse copyWith({
List? lineBarSpots,
- }) {
- return LineTouchResponse(
- lineBarSpots ?? this.lineBarSpots,
- );
- }
+ }) =>
+ LineTouchResponse(
+ lineBarSpots ?? this.lineBarSpots,
+ );
}
/// It lerps a [LineChartData] to another [LineChartData] (handles animation for updating values)
diff --git a/lib/src/chart/pie_chart/pie_chart_data.dart b/lib/src/chart/pie_chart/pie_chart_data.dart
index 37e70e7b4..1d1f1327e 100644
--- a/lib/src/chart/pie_chart/pie_chart_data.dart
+++ b/lib/src/chart/pie_chart/pie_chart_data.dart
@@ -84,18 +84,17 @@ class PieChartData extends BaseChartData with EquatableMixin {
PieTouchData? pieTouchData,
FlBorderData? borderData,
bool? titleSunbeamLayout,
- }) {
- return PieChartData(
- sections: sections ?? this.sections,
- centerSpaceRadius: centerSpaceRadius ?? this.centerSpaceRadius,
- centerSpaceColor: centerSpaceColor ?? this.centerSpaceColor,
- sectionsSpace: sectionsSpace ?? this.sectionsSpace,
- startDegreeOffset: startDegreeOffset ?? this.startDegreeOffset,
- pieTouchData: pieTouchData ?? this.pieTouchData,
- borderData: borderData ?? this.borderData,
- titleSunbeamLayout: titleSunbeamLayout ?? this.titleSunbeamLayout,
- );
- }
+ }) =>
+ PieChartData(
+ sections: sections ?? this.sections,
+ centerSpaceRadius: centerSpaceRadius ?? this.centerSpaceRadius,
+ centerSpaceColor: centerSpaceColor ?? this.centerSpaceColor,
+ sectionsSpace: sectionsSpace ?? this.sectionsSpace,
+ startDegreeOffset: startDegreeOffset ?? this.startDegreeOffset,
+ pieTouchData: pieTouchData ?? this.pieTouchData,
+ borderData: borderData ?? this.borderData,
+ titleSunbeamLayout: titleSunbeamLayout ?? this.titleSunbeamLayout,
+ );
/// Lerps a [BaseChartData] based on [t] value, check [Tween.lerp].
@override
@@ -240,52 +239,50 @@ class PieChartSectionData {
Widget? badgeWidget,
double? titlePositionPercentageOffset,
double? badgePositionPercentageOffset,
- }) {
- return PieChartSectionData(
- value: value ?? this.value,
- color: color ?? this.color,
- gradient: gradient ?? this.gradient,
- radius: radius ?? this.radius,
- showTitle: showTitle ?? this.showTitle,
- titleStyle: titleStyle ?? this.titleStyle,
- title: title ?? this.title,
- borderSide: borderSide ?? this.borderSide,
- badgeWidget: badgeWidget ?? this.badgeWidget,
- titlePositionPercentageOffset:
- titlePositionPercentageOffset ?? this.titlePositionPercentageOffset,
- badgePositionPercentageOffset:
- badgePositionPercentageOffset ?? this.badgePositionPercentageOffset,
- );
- }
+ }) =>
+ PieChartSectionData(
+ value: value ?? this.value,
+ color: color ?? this.color,
+ gradient: gradient ?? this.gradient,
+ radius: radius ?? this.radius,
+ showTitle: showTitle ?? this.showTitle,
+ titleStyle: titleStyle ?? this.titleStyle,
+ title: title ?? this.title,
+ borderSide: borderSide ?? this.borderSide,
+ badgeWidget: badgeWidget ?? this.badgeWidget,
+ titlePositionPercentageOffset:
+ titlePositionPercentageOffset ?? this.titlePositionPercentageOffset,
+ badgePositionPercentageOffset:
+ badgePositionPercentageOffset ?? this.badgePositionPercentageOffset,
+ );
/// Lerps a [PieChartSectionData] based on [t] value, check [Tween.lerp].
static PieChartSectionData lerp(
PieChartSectionData a,
PieChartSectionData b,
double t,
- ) {
- return PieChartSectionData(
- value: lerpDouble(a.value, b.value, t),
- color: Color.lerp(a.color, b.color, t),
- gradient: Gradient.lerp(a.gradient, b.gradient, t),
- radius: lerpDouble(a.radius, b.radius, t),
- showTitle: b.showTitle,
- titleStyle: TextStyle.lerp(a.titleStyle, b.titleStyle, t),
- title: b.title,
- borderSide: BorderSide.lerp(a.borderSide, b.borderSide, t),
- badgeWidget: b.badgeWidget,
- titlePositionPercentageOffset: lerpDouble(
- a.titlePositionPercentageOffset,
- b.titlePositionPercentageOffset,
- t,
- ),
- badgePositionPercentageOffset: lerpDouble(
- a.badgePositionPercentageOffset,
- b.badgePositionPercentageOffset,
- t,
- ),
- );
- }
+ ) =>
+ PieChartSectionData(
+ value: lerpDouble(a.value, b.value, t),
+ color: Color.lerp(a.color, b.color, t),
+ gradient: Gradient.lerp(a.gradient, b.gradient, t),
+ radius: lerpDouble(a.radius, b.radius, t),
+ showTitle: b.showTitle,
+ titleStyle: TextStyle.lerp(a.titleStyle, b.titleStyle, t),
+ title: b.title,
+ borderSide: BorderSide.lerp(a.borderSide, b.borderSide, t),
+ badgeWidget: b.badgeWidget,
+ titlePositionPercentageOffset: lerpDouble(
+ a.titlePositionPercentageOffset,
+ b.titlePositionPercentageOffset,
+ t,
+ ),
+ badgePositionPercentageOffset: lerpDouble(
+ a.badgePositionPercentageOffset,
+ b.badgePositionPercentageOffset,
+ t,
+ ),
+ );
}
/// Holds data to handle touch events, and touch responses in the [PieChart].
@@ -374,11 +371,10 @@ class PieTouchResponse extends BaseTouchResponse {
/// and replaces provided values.
PieTouchResponse copyWith({
PieTouchedSection? touchedSection,
- }) {
- return PieTouchResponse(
- touchedSection ?? this.touchedSection,
- );
- }
+ }) =>
+ PieTouchResponse(
+ touchedSection ?? this.touchedSection,
+ );
}
/// It lerps a [PieChartData] to another [PieChartData] (handles animation for updating values)
diff --git a/lib/src/chart/pie_chart/pie_chart_painter.dart b/lib/src/chart/pie_chart/pie_chart_painter.dart
index 9517c72ec..70331cb1d 100644
--- a/lib/src/chart/pie_chart/pie_chart_painter.dart
+++ b/lib/src/chart/pie_chart/pie_chart_painter.dart
@@ -433,6 +433,7 @@ class PieChartPainter extends BaseChartPainter {
) {
final data = holder.data;
final sectionsAngle = calculateSectionsAngle(data.sections, data.sumValue);
+ final centerRadius = calculateCenterRadius(viewSize, holder);
final center = Offset(viewSize.width / 2, viewSize.height / 2);
@@ -448,33 +449,34 @@ class PieChartPainter extends BaseChartPainter {
PieChartSectionData? foundSectionData;
var foundSectionDataPosition = -1;
- /// Find the nearest section base on the touch spot
- final relativeTouchAngle = (touchAngle - data.startDegreeOffset) % 360;
- var tempAngle = 0.0;
+ var tempAngle = data.startDegreeOffset;
for (var i = 0; i < data.sections.length; i++) {
final section = data.sections[i];
- var sectionAngle = sectionsAngle[i];
+ final sectionAngle = sectionsAngle[i];
- tempAngle %= 360;
- if (data.sections.length == 1) {
- sectionAngle = 360;
- } else {
- sectionAngle %= 360;
+ if (sectionAngle == 360) {
+ final distance = math.sqrt(
+ math.pow(localPosition.dx - center.dx, 2) +
+ math.pow(localPosition.dy - center.dy, 2),
+ );
+ if (distance >= centerRadius &&
+ distance <= section.radius + centerRadius) {
+ foundSectionData = section;
+ foundSectionDataPosition = i;
+ }
+ break;
}
- /// degree criteria
- final space = data.sectionsSpace / 2;
- final fromDegree = tempAngle + space;
- final toDegree = sectionAngle + tempAngle - space;
- final isInDegree =
- relativeTouchAngle >= fromDegree && relativeTouchAngle <= toDegree;
-
- /// radius criteria
- final centerRadius = calculateCenterRadius(viewSize, holder);
- final sectionRadius = centerRadius + section.radius;
- final isInRadius = touchR > centerRadius && touchR <= sectionRadius;
+ final sectionPath = generateSectionPath(
+ section,
+ data.sectionsSpace,
+ tempAngle,
+ sectionAngle,
+ center,
+ centerRadius,
+ );
- if (isInDegree && isInRadius) {
+ if (sectionPath.contains(localPosition)) {
foundSectionData = section;
foundSectionDataPosition = i;
break;
diff --git a/lib/src/chart/pie_chart/pie_chart_renderer.dart b/lib/src/chart/pie_chart/pie_chart_renderer.dart
index ef001a477..c528d3f7a 100644
--- a/lib/src/chart/pie_chart/pie_chart_renderer.dart
+++ b/lib/src/chart/pie_chart/pie_chart_renderer.dart
@@ -129,9 +129,8 @@ class RenderPieChart extends RenderBaseChart
}
@override
- bool hitTestChildren(BoxHitTestResult result, {required Offset position}) {
- return defaultHitTestChildren(result, position: position);
- }
+ bool hitTestChildren(BoxHitTestResult result, {required Offset position}) =>
+ defaultHitTestChildren(result, position: position);
@override
void paint(PaintingContext context, Offset offset) {
diff --git a/lib/src/chart/radar_chart/radar_chart.dart b/lib/src/chart/radar_chart/radar_chart.dart
index cab84a9f8..acd06e5dd 100644
--- a/lib/src/chart/radar_chart/radar_chart.dart
+++ b/lib/src/chart/radar_chart/radar_chart.dart
@@ -41,9 +41,7 @@ class _RadarChartState extends AnimatedWidgetBaseState {
);
}
- RadarChartData _getDate() {
- return widget.data;
- }
+ RadarChartData _getDate() => widget.data;
@override
void forEachTween(TweenVisitor visitor) {
diff --git a/lib/src/chart/radar_chart/radar_chart_data.dart b/lib/src/chart/radar_chart/radar_chart_data.dart
index a4e1ee750..58adecb43 100644
--- a/lib/src/chart/radar_chart/radar_chart_data.dart
+++ b/lib/src/chart/radar_chart/radar_chart_data.dart
@@ -377,9 +377,8 @@ class RadarEntry with EquatableMixin {
RadarEntry(value: value ?? this.value);
/// Lerps a [RadarDataSet] based on [t] value, check [Tween.lerp].
- static RadarEntry lerp(RadarEntry a, RadarEntry b, double t) {
- return RadarEntry(value: lerpDouble(a.value, b.value, t)!);
- }
+ static RadarEntry lerp(RadarEntry a, RadarEntry b, double t) =>
+ RadarEntry(value: lerpDouble(a.value, b.value, t)!);
/// Used for equality check, see [EquatableMixin].
@override
@@ -446,11 +445,10 @@ class RadarTouchResponse extends BaseTouchResponse {
/// and replaces provided values.
RadarTouchResponse copyWith({
RadarTouchedSpot? touchedSpot,
- }) {
- return RadarTouchResponse(
- touchedSpot ?? this.touchedSpot,
- );
- }
+ }) =>
+ RadarTouchResponse(
+ touchedSpot ?? this.touchedSpot,
+ );
}
/// It gives you information about the touched spot.
diff --git a/lib/src/chart/radar_chart/radar_chart_painter.dart b/lib/src/chart/radar_chart/radar_chart_painter.dart
index 5151908e6..ef62e692b 100644
--- a/lib/src/chart/radar_chart/radar_chart_painter.dart
+++ b/lib/src/chart/radar_chart/radar_chart_painter.dart
@@ -69,9 +69,7 @@ class RadarChartPainter extends BaseChartPainter {
}
@visibleForTesting
- double getDefaultChartCenterValue() {
- return 0;
- }
+ double getDefaultChartCenterValue() => 0;
double getChartCenterValue(RadarChartData data) {
final dataSetMaxValue = data.maxEntry.value;
diff --git a/lib/src/chart/scatter_chart/scatter_chart_data.dart b/lib/src/chart/scatter_chart/scatter_chart_data.dart
index cd27e50ed..fa2e5990f 100644
--- a/lib/src/chart/scatter_chart/scatter_chart_data.dart
+++ b/lib/src/chart/scatter_chart/scatter_chart_data.dart
@@ -140,26 +140,25 @@ class ScatterChartData extends AxisChartData with EquatableMixin {
FlClipData? clipData,
Color? backgroundColor,
ScatterLabelSettings? scatterLabelSettings,
- }) {
- return ScatterChartData(
- scatterSpots: scatterSpots ?? this.scatterSpots,
- titlesData: titlesData ?? this.titlesData,
- scatterTouchData: scatterTouchData ?? this.scatterTouchData,
- showingTooltipIndicators:
- showingTooltipIndicators ?? this.showingTooltipIndicators,
- gridData: gridData ?? this.gridData,
- borderData: borderData ?? this.borderData,
- minX: minX ?? this.minX,
- maxX: maxX ?? this.maxX,
- baselineX: baselineX ?? this.baselineX,
- minY: minY ?? this.minY,
- maxY: maxY ?? this.maxY,
- baselineY: baselineY ?? this.baselineY,
- clipData: clipData ?? this.clipData,
- backgroundColor: backgroundColor ?? this.backgroundColor,
- scatterLabelSettings: scatterLabelSettings ?? this.scatterLabelSettings,
- );
- }
+ }) =>
+ ScatterChartData(
+ scatterSpots: scatterSpots ?? this.scatterSpots,
+ titlesData: titlesData ?? this.titlesData,
+ scatterTouchData: scatterTouchData ?? this.scatterTouchData,
+ showingTooltipIndicators:
+ showingTooltipIndicators ?? this.showingTooltipIndicators,
+ gridData: gridData ?? this.gridData,
+ borderData: borderData ?? this.borderData,
+ minX: minX ?? this.minX,
+ maxX: maxX ?? this.maxX,
+ baselineX: baselineX ?? this.baselineX,
+ minY: minY ?? this.minY,
+ maxY: maxY ?? this.maxY,
+ baselineY: baselineY ?? this.baselineY,
+ clipData: clipData ?? this.clipData,
+ backgroundColor: backgroundColor ?? this.backgroundColor,
+ scatterLabelSettings: scatterLabelSettings ?? this.scatterLabelSettings,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -225,24 +224,22 @@ class ScatterSpot extends FlSpot with EquatableMixin {
double? y,
bool? show,
FlDotPainter? dotPainter,
- }) {
- return ScatterSpot(
- x ?? this.x,
- y ?? this.y,
- show: show ?? this.show,
- dotPainter: dotPainter ?? this.dotPainter,
- );
- }
+ }) =>
+ ScatterSpot(
+ x ?? this.x,
+ y ?? this.y,
+ show: show ?? this.show,
+ dotPainter: dotPainter ?? this.dotPainter,
+ );
/// Lerps a [ScatterSpot] based on [t] value, check [Tween.lerp].
- static ScatterSpot lerp(ScatterSpot a, ScatterSpot b, double t) {
- return ScatterSpot(
- lerpDouble(a.x, b.x, t)!,
- lerpDouble(a.y, b.y, t)!,
- show: b.show,
- dotPainter: a.dotPainter.lerp(a.dotPainter, b.dotPainter, t),
- );
- }
+ static ScatterSpot lerp(ScatterSpot a, ScatterSpot b, double t) =>
+ ScatterSpot(
+ lerpDouble(a.x, b.x, t)!,
+ lerpDouble(a.y, b.y, t)!,
+ show: b.show,
+ dotPainter: a.dotPainter.lerp(a.dotPainter, b.dotPainter, t),
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -314,17 +311,16 @@ class ScatterTouchData extends FlTouchData
ScatterTouchTooltipData? touchTooltipData,
double? touchSpotThreshold,
bool? handleBuiltInTouches,
- }) {
- return ScatterTouchData(
- enabled: enabled ?? this.enabled,
- touchCallback: touchCallback ?? this.touchCallback,
- mouseCursorResolver: mouseCursorResolver ?? this.mouseCursorResolver,
- longPressDuration: longPressDuration ?? this.longPressDuration,
- touchTooltipData: touchTooltipData ?? this.touchTooltipData,
- handleBuiltInTouches: handleBuiltInTouches ?? this.handleBuiltInTouches,
- touchSpotThreshold: touchSpotThreshold ?? this.touchSpotThreshold,
- );
- }
+ }) =>
+ ScatterTouchData(
+ enabled: enabled ?? this.enabled,
+ touchCallback: touchCallback ?? this.touchCallback,
+ mouseCursorResolver: mouseCursorResolver ?? this.mouseCursorResolver,
+ longPressDuration: longPressDuration ?? this.longPressDuration,
+ touchTooltipData: touchTooltipData ?? this.touchTooltipData,
+ handleBuiltInTouches: handleBuiltInTouches ?? this.handleBuiltInTouches,
+ touchSpotThreshold: touchSpotThreshold ?? this.touchSpotThreshold,
+ );
/// Used for equality check, see [EquatableMixin].
@override
@@ -388,9 +384,8 @@ class ScatterTouchedSpot with EquatableMixin {
ScatterTouchedSpot copyWith({
ScatterSpot? spot,
int? spotIndex,
- }) {
- return ScatterTouchedSpot(spot ?? this.spot, spotIndex ?? this.spotIndex);
- }
+ }) =>
+ ScatterTouchedSpot(spot ?? this.spot, spotIndex ?? this.spotIndex);
}
/// Holds representation data for showing tooltip popup on top of spots.
@@ -497,24 +492,23 @@ class ScatterTouchTooltipData with EquatableMixin {
double? rotateAngle,
BorderSide? tooltipBorder,
GetScatterTooltipColor? getTooltipColor,
- }) {
- return ScatterTouchTooltipData(
- tooltipRoundedRadius: tooltipRoundedRadius ?? this.tooltipRoundedRadius,
- tooltipPadding: tooltipPadding ?? this.tooltipPadding,
- tooltipHorizontalAlignment:
- tooltipHorizontalAlignment ?? this.tooltipHorizontalAlignment,
- tooltipHorizontalOffset:
- tooltipHorizontalOffset ?? this.tooltipHorizontalOffset,
- maxContentWidth: maxContentWidth ?? this.maxContentWidth,
- getTooltipItems: getTooltipItems ?? this.getTooltipItems,
- fitInsideHorizontally:
- fitInsideHorizontally ?? this.fitInsideHorizontally,
- fitInsideVertically: fitInsideVertically ?? this.fitInsideVertically,
- rotateAngle: rotateAngle ?? this.rotateAngle,
- tooltipBorder: tooltipBorder ?? this.tooltipBorder,
- getTooltipColor: getTooltipColor ?? this.getTooltipColor,
- );
- }
+ }) =>
+ ScatterTouchTooltipData(
+ tooltipRoundedRadius: tooltipRoundedRadius ?? this.tooltipRoundedRadius,
+ tooltipPadding: tooltipPadding ?? this.tooltipPadding,
+ tooltipHorizontalAlignment:
+ tooltipHorizontalAlignment ?? this.tooltipHorizontalAlignment,
+ tooltipHorizontalOffset:
+ tooltipHorizontalOffset ?? this.tooltipHorizontalOffset,
+ maxContentWidth: maxContentWidth ?? this.maxContentWidth,
+ getTooltipItems: getTooltipItems ?? this.getTooltipItems,
+ fitInsideHorizontally:
+ fitInsideHorizontally ?? this.fitInsideHorizontally,
+ fitInsideVertically: fitInsideVertically ?? this.fitInsideVertically,
+ rotateAngle: rotateAngle ?? this.rotateAngle,
+ tooltipBorder: tooltipBorder ?? this.tooltipBorder,
+ getTooltipColor: getTooltipColor ?? this.getTooltipColor,
+ );
}
/// Provides a [ScatterTooltipItem] for showing content inside the [ScatterTouchTooltipData].
@@ -557,9 +551,8 @@ typedef GetScatterTooltipColor = Color Function(
);
/// Default implementation for [ScatterTouchTooltipData.getTooltipItems].
-Color defaultScatterTooltipColor(ScatterSpot touchedSpot) {
- return Colors.blueGrey.darken(15);
-}
+Color defaultScatterTooltipColor(ScatterSpot touchedSpot) =>
+ Colors.blueGrey.darken(15);
/// Holds data of showing each item in the tooltip popup.
class ScatterTooltipItem with EquatableMixin {
@@ -614,16 +607,15 @@ class ScatterTooltipItem with EquatableMixin {
TextAlign? textAlign,
TextDirection? textDirection,
List? children,
- }) {
- return ScatterTooltipItem(
- text ?? this.text,
- textStyle: textStyle ?? this.textStyle,
- bottomMargin: bottomMargin ?? this.bottomMargin,
- textAlign: textAlign ?? this.textAlign,
- textDirection: textDirection ?? this.textDirection,
- children: children ?? this.children,
- );
- }
+ }) =>
+ ScatterTooltipItem(
+ text ?? this.text,
+ textStyle: textStyle ?? this.textStyle,
+ bottomMargin: bottomMargin ?? this.bottomMargin,
+ textAlign: textAlign ?? this.textAlign,
+ textDirection: textDirection ?? this.textDirection,
+ children: children ?? this.children,
+ );
}
/// It lerps a [ScatterChartData] to another [ScatterChartData] (handles animation for updating values)
@@ -635,9 +627,7 @@ class ScatterChartDataTween extends Tween {
/// Lerps a [ScatterChartData] based on [t] value, check [Tween.lerp].
@override
- ScatterChartData lerp(double t) {
- return begin!.lerp(begin!, end!, t);
- }
+ ScatterChartData lerp(double t) => begin!.lerp(begin!, end!, t);
}
/// It gives you the index value as well as the spot and gets the text style of the label.
@@ -714,14 +704,13 @@ class ScatterLabelSettings with EquatableMixin {
ScatterLabelSettings a,
ScatterLabelSettings b,
double t,
- ) {
- return ScatterLabelSettings(
- showLabel: b.showLabel,
- getLabelTextStyleFunction: b.getLabelTextStyleFunction,
- getLabelFunction: b.getLabelFunction,
- textDirection: b.textDirection,
- );
- }
+ ) =>
+ ScatterLabelSettings(
+ showLabel: b.showLabel,
+ getLabelTextStyleFunction: b.getLabelTextStyleFunction,
+ getLabelFunction: b.getLabelFunction,
+ textDirection: b.textDirection,
+ );
/// Used for equality check, see [EquatableMixin].
@override
diff --git a/lib/src/extensions/fl_border_data_extension.dart b/lib/src/extensions/fl_border_data_extension.dart
index e6002dba6..64a6469d9 100644
--- a/lib/src/extensions/fl_border_data_extension.dart
+++ b/lib/src/extensions/fl_border_data_extension.dart
@@ -2,12 +2,10 @@ import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/widgets.dart';
extension FlBorderDataExtension on FlBorderData {
- EdgeInsets get allSidesPadding {
- return EdgeInsets.only(
- left: show ? border.left.width : 0.0,
- top: show ? border.top.width : 0.0,
- right: show ? border.right.width : 0.0,
- bottom: show ? border.bottom.width : 0.0,
- );
- }
+ EdgeInsets get allSidesPadding => EdgeInsets.only(
+ left: show ? border.left.width : 0.0,
+ top: show ? border.top.width : 0.0,
+ right: show ? border.right.width : 0.0,
+ bottom: show ? border.bottom.width : 0.0,
+ );
}
diff --git a/lib/src/extensions/fl_titles_data_extension.dart b/lib/src/extensions/fl_titles_data_extension.dart
index 8bf5d3b69..28565d749 100644
--- a/lib/src/extensions/fl_titles_data_extension.dart
+++ b/lib/src/extensions/fl_titles_data_extension.dart
@@ -3,12 +3,10 @@ import 'package:fl_chart/src/extensions/side_titles_extension.dart';
import 'package:flutter/widgets.dart';
extension FlTitlesDataExtension on FlTitlesData {
- EdgeInsets get allSidesPadding {
- return EdgeInsets.only(
- left: show ? leftTitles.totalReservedSize : 0.0,
- top: show ? topTitles.totalReservedSize : 0.0,
- right: show ? rightTitles.totalReservedSize : 0.0,
- bottom: show ? bottomTitles.totalReservedSize : 0.0,
- );
- }
+ EdgeInsets get allSidesPadding => EdgeInsets.only(
+ left: show ? leftTitles.totalReservedSize : 0.0,
+ top: show ? topTitles.totalReservedSize : 0.0,
+ right: show ? rightTitles.totalReservedSize : 0.0,
+ bottom: show ? bottomTitles.totalReservedSize : 0.0,
+ );
}
diff --git a/lib/src/utils/path_drawing/dash_path.dart b/lib/src/utils/path_drawing/dash_path.dart
index de5b299ff..9f5e6893c 100644
--- a/lib/src/utils/path_drawing/dash_path.dart
+++ b/lib/src/utils/path_drawing/dash_path.dart
@@ -60,11 +60,8 @@ class DashOffset {
final double _rawVal;
final _DashOffsetType _dashOffsetType;
- double _calculate(double length) {
- return _dashOffsetType == _DashOffsetType.absolute
- ? _rawVal
- : length * _rawVal;
- }
+ double _calculate(double length) =>
+ _dashOffsetType == _DashOffsetType.absolute ? _rawVal : length * _rawVal;
}
/// A circular array of dash offsets and lengths.
diff --git a/lib/src/utils/utils.dart b/lib/src/utils/utils.dart
index 8f63bf5a0..acdde3c9e 100644
--- a/lib/src/utils/utils.dart
+++ b/lib/src/utils/utils.dart
@@ -324,7 +324,5 @@ class Utils {
}
/// Converts radius number to sigma for drawing shadows
- double convertRadiusToSigma(double radius) {
- return radius * 0.57735 + 0.5;
- }
+ double convertRadiusToSigma(double radius) => radius * 0.57735 + 0.5;
}