From 99c92dbd947c6c139542925f1d1a4cef101c0a5c Mon Sep 17 00:00:00 2001 From: Oleh Marchenko Date: Thu, 9 Nov 2023 17:57:36 +0200 Subject: [PATCH] upgraded deps, fixed linter issues, added repaint boundaries to all charts --- example/lib/main.dart | 11 +-- example/lib/src/bar_chart.dart | 24 ++--- example/lib/src/gauge_chart.dart | 14 +-- example/lib/src/line_chart.dart | 16 ++-- .../lib/src/scaffolds/example_scaffold.dart | 7 +- example/lib/src/scaffolds/setup_scaffold.dart | 13 ++- example/lib/src/widgets/button.dart | 4 +- example/lib/src/widgets/color_list_tile.dart | 7 +- example/lib/src/widgets/dialog_list_tile.dart | 7 +- example/lib/src/widgets/grid.dart | 4 +- example/lib/src/widgets/number_list_tile.dart | 4 +- example/pubspec.yaml | 6 +- example/windows/runner/Runner.rc | 10 +-- lib/src/bar/chart.dart | 90 +++++++++---------- lib/src/bar/painter.dart | 12 +-- lib/src/gauge/chart.dart | 46 +++++----- lib/src/line/chart.dart | 24 ++--- pubspec.yaml | 6 +- 18 files changed, 150 insertions(+), 155 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 6b40609..1737067 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -15,7 +15,7 @@ void main() { } class App extends StatelessWidget { - const App({Key? key}) : super(key: key); + const App({super.key}); @override Widget build(BuildContext context) { @@ -29,14 +29,9 @@ class App extends StatelessWidget { } } -class HomePage extends StatefulWidget { - const HomePage({Key? key}) : super(key: key); +class HomePage extends StatelessWidget { + const HomePage({super.key}); - @override - _HomePageState createState() => _HomePageState(); -} - -class _HomePageState extends State { @override Widget build(BuildContext context) { return const ExampleScaffold( diff --git a/example/lib/src/bar_chart.dart b/example/lib/src/bar_chart.dart index a3eb85a..050dfb0 100644 --- a/example/lib/src/bar_chart.dart +++ b/example/lib/src/bar_chart.dart @@ -36,7 +36,7 @@ final _data = BehaviorSubject.seeded(BarChartData( )); class BarChartExample extends StatelessWidget { - const BarChartExample({Key? key}) : super(key: key); + const BarChartExample({super.key}); @override Widget build(BuildContext context) { @@ -68,7 +68,7 @@ class BarChartExample extends StatelessWidget { } class _Chart extends StatelessWidget { - const _Chart({Key? key}) : super(key: key); + const _Chart(); @override Widget build(BuildContext context) { @@ -99,7 +99,7 @@ class _Chart extends StatelessWidget { } class _GeneralDataSetupGroup extends StatelessWidget { - const _GeneralDataSetupGroup({Key? key}) : super(key: key); + const _GeneralDataSetupGroup(); @override Widget build(BuildContext context) { @@ -255,7 +255,7 @@ class _GeneralDataSetupGroup extends StatelessWidget { } class _GeneralSettingsSetupGroup extends StatelessWidget { - const _GeneralSettingsSetupGroup({Key? key}) : super(key: key); + const _GeneralSettingsSetupGroup(); @override Widget build(BuildContext context) { @@ -341,7 +341,7 @@ class _GeneralSettingsSetupGroup extends StatelessWidget { } class _BarAlignmentSetupGroup extends StatelessWidget { - const _BarAlignmentSetupGroup({Key? key}) : super(key: key); + const _BarAlignmentSetupGroup(); @override Widget build(BuildContext context) { @@ -371,7 +371,7 @@ class _BarAlignmentSetupGroup extends StatelessWidget { } class _BarFitSetupGroup extends StatelessWidget { - const _BarFitSetupGroup({Key? key}) : super(key: key); + const _BarFitSetupGroup(); @override Widget build(BuildContext context) { @@ -400,7 +400,7 @@ class _BarFitSetupGroup extends StatelessWidget { } class _YAxisLayoutSetupGroup extends StatelessWidget { - const _YAxisLayoutSetupGroup({Key? key}) : super(key: key); + const _YAxisLayoutSetupGroup(); @override Widget build(BuildContext context) { @@ -430,7 +430,7 @@ class _YAxisLayoutSetupGroup extends StatelessWidget { } class _AxisDivisionsEdgesSetupGroup extends StatelessWidget { - const _AxisDivisionsEdgesSetupGroup({Key? key}) : super(key: key); + const _AxisDivisionsEdgesSetupGroup(); @override Widget build(BuildContext context) { @@ -460,7 +460,7 @@ class _AxisDivisionsEdgesSetupGroup extends StatelessWidget { } class _GridStyleSetupGroup extends StatelessWidget { - const _GridStyleSetupGroup({Key? key}) : super(key: key); + const _GridStyleSetupGroup(); @override Widget build(BuildContext context) { @@ -507,7 +507,7 @@ class _GridStyleSetupGroup extends StatelessWidget { } class _AxisStyleSetupGroup extends StatelessWidget { - const _AxisStyleSetupGroup({Key? key}) : super(key: key); + const _AxisStyleSetupGroup(); @override Widget build(BuildContext context) { @@ -596,7 +596,7 @@ class _AxisStyleSetupGroup extends StatelessWidget { } class _BarStyleSetupGroup extends StatelessWidget { - const _BarStyleSetupGroup({Key? key}) : super(key: key); + const _BarStyleSetupGroup(); @override Widget build(BuildContext context) { @@ -811,7 +811,7 @@ class _BarStyleSetupGroup extends StatelessWidget { } class _BardBorderSetupGroup extends StatelessWidget { - const _BardBorderSetupGroup({Key? key}) : super(key: key); + const _BardBorderSetupGroup(); @override Widget build(BuildContext context) { diff --git a/example/lib/src/gauge_chart.dart b/example/lib/src/gauge_chart.dart index 2b0d449..4e636b6 100644 --- a/example/lib/src/gauge_chart.dart +++ b/example/lib/src/gauge_chart.dart @@ -29,7 +29,7 @@ final _data = BehaviorSubject.seeded( ); class GaugeChartExample extends StatelessWidget { - const GaugeChartExample({Key? key}) : super(key: key); + const GaugeChartExample({super.key}); @override Widget build(BuildContext context) { @@ -51,7 +51,7 @@ class GaugeChartExample extends StatelessWidget { } class _Chart extends StatelessWidget { - const _Chart({Key? key}) : super(key: key); + const _Chart(); @override Widget build(BuildContext context) { @@ -90,7 +90,7 @@ class _Chart extends StatelessWidget { } class _GeneralDataSetupGroup extends StatelessWidget { - const _GeneralDataSetupGroup({Key? key}) : super(key: key); + const _GeneralDataSetupGroup(); List getRandomizedData({required bool fixedQty}) { if (fixedQty) { @@ -141,7 +141,7 @@ class _GeneralDataSetupGroup extends StatelessWidget { } class _GeneralSettingsSetupGroup extends StatelessWidget { - const _GeneralSettingsSetupGroup({Key? key}) : super(key: key); + const _GeneralSettingsSetupGroup(); @override Widget build(BuildContext context) { @@ -213,7 +213,7 @@ class _GeneralSettingsSetupGroup extends StatelessWidget { } class _BackgroundStyleSetupGroup extends StatelessWidget { - const _BackgroundStyleSetupGroup({Key? key}) : super(key: key); + const _BackgroundStyleSetupGroup(); @override Widget build(BuildContext context) { @@ -271,7 +271,7 @@ class _BackgroundStyleSetupGroup extends StatelessWidget { } class _BackgroundBorderStyleSetupGroup extends StatelessWidget { - const _BackgroundBorderStyleSetupGroup({Key? key}) : super(key: key); + const _BackgroundBorderStyleSetupGroup(); @override Widget build(BuildContext context) { @@ -392,7 +392,7 @@ class _BackgroundBorderStyleSetupGroup extends StatelessWidget { } class _SectionStyleSetupGroup extends StatelessWidget { - const _SectionStyleSetupGroup({Key? key}) : super(key: key); + const _SectionStyleSetupGroup(); @override Widget build(BuildContext context) { diff --git a/example/lib/src/line_chart.dart b/example/lib/src/line_chart.dart index 7bdba5a..5b26711 100644 --- a/example/lib/src/line_chart.dart +++ b/example/lib/src/line_chart.dart @@ -54,7 +54,7 @@ final _data = BehaviorSubject.seeded(LineChartData( )); class LineChartExample extends StatelessWidget { - const LineChartExample({Key? key}) : super(key: key); + const LineChartExample({super.key}); @override Widget build(BuildContext context) { @@ -78,7 +78,7 @@ class LineChartExample extends StatelessWidget { } class _Chart extends StatelessWidget { - const _Chart({Key? key}) : super(key: key); + const _Chart(); @override Widget build(BuildContext context) { @@ -109,7 +109,7 @@ class _Chart extends StatelessWidget { } class _GeneralDataSetupGroup extends StatelessWidget { - const _GeneralDataSetupGroup({Key? key}) : super(key: key); + const _GeneralDataSetupGroup(); Map getRandomizedData({required bool positive}) { final year = DateTime.now().year; @@ -241,7 +241,7 @@ class _GeneralDataSetupGroup extends StatelessWidget { } class _GridTypeSetupGroup extends StatelessWidget { - const _GridTypeSetupGroup({Key? key}) : super(key: key); + const _GridTypeSetupGroup(); @override Widget build(BuildContext context) { @@ -269,7 +269,7 @@ class _GridTypeSetupGroup extends StatelessWidget { } class _DataTypeSetupGroup extends StatelessWidget { - const _DataTypeSetupGroup({Key? key}) : super(key: key); + const _DataTypeSetupGroup(); @override Widget build(BuildContext context) { @@ -297,7 +297,7 @@ class _DataTypeSetupGroup extends StatelessWidget { } class _GeneralSettingsSetupGroup extends StatelessWidget { - const _GeneralSettingsSetupGroup({Key? key}) : super(key: key); + const _GeneralSettingsSetupGroup(); @override Widget build(BuildContext context) { @@ -388,7 +388,7 @@ class _GeneralSettingsSetupGroup extends StatelessWidget { } class _AxisDivisionsEdgesSetupGroup extends StatelessWidget { - const _AxisDivisionsEdgesSetupGroup({Key? key}) : super(key: key); + const _AxisDivisionsEdgesSetupGroup(); @override Widget build(BuildContext context) { @@ -418,7 +418,7 @@ class _AxisDivisionsEdgesSetupGroup extends StatelessWidget { } class _LimitLabelSnapPositionSetupGroup extends StatelessWidget { - const _LimitLabelSnapPositionSetupGroup({Key? key}) : super(key: key); + const _LimitLabelSnapPositionSetupGroup(); @override Widget build(BuildContext context) { diff --git a/example/lib/src/scaffolds/example_scaffold.dart b/example/lib/src/scaffolds/example_scaffold.dart index 5644eae..825ee29 100644 --- a/example/lib/src/scaffolds/example_scaffold.dart +++ b/example/lib/src/scaffolds/example_scaffold.dart @@ -9,9 +9,9 @@ final _selected = BehaviorSubject.seeded(0); class ExampleScaffold extends StatelessWidget { const ExampleScaffold({ - Key? key, + super.key, required this.tabs, - }) : super(key: key); + }); final Map tabs; @@ -45,9 +45,8 @@ class ExampleScaffold extends StatelessWidget { class _AppMenu extends StatelessWidget implements PreferredSizeWidget { const _AppMenu({ - Key? key, required this.tabs, - }) : super(key: key); + }); final List tabs; diff --git a/example/lib/src/scaffolds/setup_scaffold.dart b/example/lib/src/scaffolds/setup_scaffold.dart index 808ed7d..6fb7483 100644 --- a/example/lib/src/scaffolds/setup_scaffold.dart +++ b/example/lib/src/scaffolds/setup_scaffold.dart @@ -8,10 +8,10 @@ const setupWidth = 315.0; class SetupScaffold extends StatefulWidget { const SetupScaffold({ - Key? key, + super.key, required this.setupChildren, required this.body, - }) : super(key: key); + }); final List setupChildren; final Widget body; @@ -121,10 +121,9 @@ class _SetupScaffoldState extends State class _Setup extends StatelessWidget { const _Setup({ - Key? key, required this.controller, required this.children, - }) : super(key: key); + }); final ScrollController controller; final List children; @@ -157,7 +156,7 @@ class _Setup extends StatelessWidget { } class SetupDivider extends StatelessWidget { - const SetupDivider({Key? key}) : super(key: key); + const SetupDivider({super.key}); @override Widget build(BuildContext context) { @@ -171,10 +170,10 @@ class SetupDivider extends StatelessWidget { class SetupGroup extends StatelessWidget { const SetupGroup({ - Key? key, + super.key, required this.title, required this.children, - }) : super(key: key); + }); final String title; final List children; diff --git a/example/lib/src/widgets/button.dart b/example/lib/src/widgets/button.dart index 1e2685c..dc2c43f 100644 --- a/example/lib/src/widgets/button.dart +++ b/example/lib/src/widgets/button.dart @@ -2,10 +2,10 @@ import 'package:flutter/material.dart'; class Button extends StatelessWidget { const Button({ - Key? key, + super.key, required this.title, required this.onPressed, - }) : super(key: key); + }); final Widget title; final VoidCallback onPressed; diff --git a/example/lib/src/widgets/color_list_tile.dart b/example/lib/src/widgets/color_list_tile.dart index 38f2587..bc50d41 100644 --- a/example/lib/src/widgets/color_list_tile.dart +++ b/example/lib/src/widgets/color_list_tile.dart @@ -7,11 +7,11 @@ import 'package:flutter_colorpicker/flutter_colorpicker.dart'; class ColorListTile extends StatelessWidget { const ColorListTile({ - Key? key, + super.key, this.title, required this.value, required this.onChanged, - }) : super(key: key); + }); final Widget? title; final Color value; @@ -43,10 +43,9 @@ class ColorListTile extends StatelessWidget { class _Dialog extends StatefulWidget { const _Dialog({ - Key? key, required this.title, required this.value, - }) : super(key: key); + }); final Widget? title; final Color value; diff --git a/example/lib/src/widgets/dialog_list_tile.dart b/example/lib/src/widgets/dialog_list_tile.dart index 5caf71c..0084145 100644 --- a/example/lib/src/widgets/dialog_list_tile.dart +++ b/example/lib/src/widgets/dialog_list_tile.dart @@ -7,12 +7,12 @@ import 'package:flutter/services.dart'; class DialogListTile extends StatelessWidget { const DialogListTile({ - Key? key, + super.key, this.title, required this.value, required this.onChanged, this.keyboardType = TextInputType.text, - }) : super(key: key); + }); final Widget? title; final String? value; @@ -48,11 +48,10 @@ class DialogListTile extends StatelessWidget { class _Dialog extends StatefulWidget { const _Dialog({ - Key? key, required this.title, required this.value, required this.keyboardType, - }) : super(key: key); + }); final Widget? title; final String? value; diff --git a/example/lib/src/widgets/grid.dart b/example/lib/src/widgets/grid.dart index ba8c9b7..611368d 100644 --- a/example/lib/src/widgets/grid.dart +++ b/example/lib/src/widgets/grid.dart @@ -6,11 +6,11 @@ import 'package:flutter/material.dart'; class Grid extends StatelessWidget { const Grid({ - Key? key, + super.key, required this.rows, required this.columns, required this.children, - }) : super(key: key); + }); final int rows; final int columns; diff --git a/example/lib/src/widgets/number_list_tile.dart b/example/lib/src/widgets/number_list_tile.dart index 607f0cf..dca782d 100644 --- a/example/lib/src/widgets/number_list_tile.dart +++ b/example/lib/src/widgets/number_list_tile.dart @@ -6,11 +6,11 @@ import 'package:flutter/material.dart'; class IntListTile extends StatelessWidget { const IntListTile({ - Key? key, + super.key, this.title, required this.value, required this.onChanged, - }) : super(key: key); + }); final Widget? title; final int value; diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 4886b9f..c2941c8 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -2,7 +2,7 @@ name: mdcharts_example description: Demonstrates how to use the mdcharts package. environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=3.0.5 <5.0.0' dependencies: flutter: @@ -11,12 +11,12 @@ dependencies: mdcharts: path: ../ - intl: ^0.17.0 + intl: ^0.18.1 rxdart: ^0.27.3 flutter_colorpicker: ^1.0.3 dev_dependencies: - flutter_lints: ^1.0.0 + flutter_lints: ^3.0.1 flutter: uses-material-design: true diff --git a/example/windows/runner/Runner.rc b/example/windows/runner/Runner.rc index 9206563..7d866f9 100644 --- a/example/windows/runner/Runner.rc +++ b/example/windows/runner/Runner.rc @@ -60,14 +60,14 @@ IDI_APP_ICON ICON "resources\\app_icon.ico" // Version // -#ifdef FLUTTER_BUILD_NUMBER -#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD #else -#define VERSION_AS_NUMBER 1,0,0 +#define VERSION_AS_NUMBER 1,0,0,0 #endif -#ifdef FLUTTER_BUILD_NAME -#define VERSION_AS_STRING #FLUTTER_BUILD_NAME +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION #else #define VERSION_AS_STRING "1.0.0" #endif diff --git a/lib/src/bar/chart.dart b/lib/src/bar/chart.dart index 3988799..f739fa1 100644 --- a/lib/src/bar/chart.dart +++ b/lib/src/bar/chart.dart @@ -18,12 +18,12 @@ import 'style.dart'; class BarChart extends StatefulWidget { /// Constructs an instance of [BarChart]. const BarChart({ - Key? key, + super.key, required this.data, this.style = const BarChartStyle(), this.settings = const BarChartSettings(), this.padding, - }) : super(key: key); + }); /// Set of required (and optional) data to construct the bar chart. final BarChartData data; @@ -103,10 +103,10 @@ class _BarChartState extends State DateTime key; if (_settings.fit == BarFit.contain) { - double _getChartWidth(double itemWidth, double itemSpacing) => + double getChartWidth(double itemWidth, double itemSpacing) => _data.data.length * (itemSpacing + itemWidth) - itemSpacing; - maxChartWidth = _getChartWidth(itemWidth, itemSpacing); + maxChartWidth = getChartWidth(itemWidth, itemSpacing); var barWidth = _style.barStyle.width; final decreaseCoef = itemSpacing / barWidth; @@ -116,7 +116,7 @@ class _BarChartState extends State barWidth -= 1; itemSpacing -= decreaseCoef; itemWidth = _getItemWidth(barWidth); - maxChartWidth = _getChartWidth(itemWidth, itemSpacing); + maxChartWidth = getChartWidth(itemWidth, itemSpacing); } } @@ -360,10 +360,10 @@ class _BarChartState extends State void recalculateSizes() { if (_settings.fit == BarFit.contain) { - double _getChartWidth(double itemWidth, double itemSpacing) => + double getChartWidth(double itemWidth, double itemSpacing) => _data.data.length * (itemSpacing + itemWidth) - itemSpacing; - maxWidth = _getChartWidth(maxItemWidth, itemSpacing); + maxWidth = getChartWidth(maxItemWidth, itemSpacing); var barWidth = _style.barStyle.width; final decreaseCoef = itemSpacing / barWidth; @@ -375,7 +375,7 @@ class _BarChartState extends State barWidth -= 1; itemSpacing -= decreaseCoef; maxItemWidth = _getItemWidth(barWidth); - maxWidth = _getChartWidth(maxItemWidth, itemSpacing); + maxWidth = getChartWidth(maxItemWidth, itemSpacing); } } } @@ -519,13 +519,12 @@ class _BarChartState extends State class _Grid extends StatelessWidget { const _Grid({ - Key? key, required this.data, required this.style, required this.settings, required this.padding, required this.yAxisLabelWidth, - }) : super(key: key); + }); final BarChartData data; final BarChartStyle style; @@ -573,14 +572,13 @@ class _Grid extends StatelessWidget { class _XAxisLabel extends StatelessWidget { const _XAxisLabel({ - Key? key, required this.settings, required this.style, required this.data, required this.index, required this.maxWidth, required this.selectedPeriod, - }) : super(key: key); + }); final BarChartSettings settings; final BarChartAxisStyle style; @@ -619,41 +617,43 @@ class _XAxisLabel extends StatelessWidget { ); } - return GestureDetector( - onTap: () => selectedPeriod.add(currentDate), - child: StreamBuilder( - stream: selectedPeriod.stream, - initialData: data.selectedPeriod, - builder: (context, selectedPeriod) { - final isSelected = currentDate == selectedPeriod.requireData; - final currentStyle = isSelected - ? style.xAxisSelectedLabelStyle - : style.xAxisLabelStyle; - final currentDecoration = isSelected - ? BoxDecoration( - borderRadius: style.xAxisSelectedLabelBorderRadius, - color: style.xAxisSelectedLabelBackgroundColor, - ) - : null; - final maxHeight = getEstimatedHeight(style, currentStyle); - - return Container( - color: Colors.transparent, - padding: EdgeInsets.only(top: style.xAxisLabelTopMargin), - child: SizedOverflowBox( - size: Size(maxWidth, maxHeight), - child: Container( - padding: style.xAxisLabelPadding, - decoration: currentDecoration, - child: Text.rich( - data.xAxisLabelBuilder(currentDate, currentStyle), - style: currentStyle, - textAlign: TextAlign.center, + return RepaintBoundary( + child: GestureDetector( + onTap: () => selectedPeriod.add(currentDate), + child: StreamBuilder( + stream: selectedPeriod.stream, + initialData: data.selectedPeriod, + builder: (context, selectedPeriod) { + final isSelected = currentDate == selectedPeriod.requireData; + final currentStyle = isSelected + ? style.xAxisSelectedLabelStyle + : style.xAxisLabelStyle; + final currentDecoration = isSelected + ? BoxDecoration( + borderRadius: style.xAxisSelectedLabelBorderRadius, + color: style.xAxisSelectedLabelBackgroundColor, + ) + : null; + final maxHeight = getEstimatedHeight(style, currentStyle); + + return Container( + color: Colors.transparent, + padding: EdgeInsets.only(top: style.xAxisLabelTopMargin), + child: SizedOverflowBox( + size: Size(maxWidth, maxHeight), + child: Container( + padding: style.xAxisLabelPadding, + decoration: currentDecoration, + child: Text.rich( + data.xAxisLabelBuilder(currentDate, currentStyle), + style: currentStyle, + textAlign: TextAlign.center, + ), ), ), - ), - ); - }, + ); + }, + ), ), ); } diff --git a/lib/src/bar/painter.dart b/lib/src/bar/painter.dart index 21b39ab..976ae77 100644 --- a/lib/src/bar/painter.dart +++ b/lib/src/bar/painter.dart @@ -105,23 +105,23 @@ class BarChartPainter extends CustomPainter { var barWidth = style.barStyle.width; var itemSpacing = settings.itemSpacing; - double _getItemWidth(double barWidth) => + double getItemWidth(double barWidth) => barWidth * barItemQuantity + barSpacing * (barItemQuantity - 1); - var itemWidth = _getItemWidth(barWidth); + var itemWidth = getItemWidth(barWidth); if (settings.fit == BarFit.contain) { - double _getChartWidth(double itemWidth, double itemSpacing) => + double getChartWidth(double itemWidth, double itemSpacing) => data.data.length * (itemSpacing + itemWidth) - itemSpacing; - var chartWidth = _getChartWidth(itemWidth, itemSpacing); + var chartWidth = getChartWidth(itemWidth, itemSpacing); final decreaseCoef = itemSpacing / barWidth; while (chartWidth > size.width) { barWidth -= 1; itemSpacing -= decreaseCoef; - itemWidth = _getItemWidth(barWidth); - chartWidth = _getChartWidth(itemWidth, itemSpacing); + itemWidth = getItemWidth(barWidth); + chartWidth = getChartWidth(itemWidth, itemSpacing); } } diff --git a/lib/src/gauge/chart.dart b/lib/src/gauge/chart.dart index 5010fc0..b64f1d4 100644 --- a/lib/src/gauge/chart.dart +++ b/lib/src/gauge/chart.dart @@ -15,12 +15,12 @@ import 'style.dart'; class GaugeChart extends StatefulWidget { /// Constructs an instance of [GaugeChart]. const GaugeChart({ - Key? key, + super.key, required this.data, this.style = const GaugeChartStyle(), this.settings = const GaugeChartSettings(), this.onSelectionChanged, - }) : super(key: key); + }); /// Set of required (and optional) data to construct the line chart. final GaugeChartData data; @@ -148,26 +148,28 @@ class _GaugeChartState extends State @override Widget build(BuildContext context) { - return GestureDetector( - onTapUp: widget.settings.selectionEnabled - ? (details) => hitTest(details.localPosition) - : null, - child: AnimatedBuilder( - animation: _valueAnimation, - builder: (context, _) { - return CustomPaint( - isComplex: true, - painter: GaugeChartPainter( - data, - widget.style, - widget.settings, - oldData!, - dataHashCode!, - _valueAnimation.value, - ), - size: Size.infinite, - ); - }, + return RepaintBoundary( + child: GestureDetector( + onTapUp: widget.settings.selectionEnabled + ? (details) => hitTest(details.localPosition) + : null, + child: AnimatedBuilder( + animation: _valueAnimation, + builder: (context, _) { + return CustomPaint( + isComplex: true, + painter: GaugeChartPainter( + data, + widget.style, + widget.settings, + oldData!, + dataHashCode!, + _valueAnimation.value, + ), + size: Size.infinite, + ); + }, + ), ), ); } diff --git a/lib/src/line/chart.dart b/lib/src/line/chart.dart index 9f0f57b..3aa085e 100644 --- a/lib/src/line/chart.dart +++ b/lib/src/line/chart.dart @@ -15,12 +15,12 @@ import 'style.dart'; class LineChart extends StatefulWidget { /// Constructs an instance of [LineChart]. const LineChart({ - Key? key, + super.key, required this.data, this.style = const LineChartStyle(), this.settings = const LineChartSettings(), this.padding, - }) : super(key: key); + }); /// Set of required (and optional) data to construct the line chart. final LineChartData data; @@ -171,15 +171,17 @@ class _LineChartState extends State child = chart; } - return Padding( - padding: widget.padding ?? - EdgeInsets.fromLTRB( - widget.style.pointStyle.tooltipHorizontalOverflowWidth, - widget.style.pointStyle.tooltipHeight, - widget.style.pointStyle.tooltipHorizontalOverflowWidth, - 0, - ), - child: child, + return RepaintBoundary( + child: Padding( + padding: widget.padding ?? + EdgeInsets.fromLTRB( + widget.style.pointStyle.tooltipHorizontalOverflowWidth, + widget.style.pointStyle.tooltipHeight, + widget.style.pointStyle.tooltipHorizontalOverflowWidth, + 0, + ), + child: child, + ), ); } diff --git a/pubspec.yaml b/pubspec.yaml index e9b8e39..a4a8684 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ issue_tracker: https://github.com/marchdev-tk/mdcharts/issues description: march.dev charts library. Provides highly customizable and configurable charts. environment: - sdk: '>=2.17.0 <3.0.0' + sdk: '>=3.0.5 <5.0.0' dependencies: flutter: @@ -15,7 +15,7 @@ dependencies: sdk: flutter # common - meta: ^1.7.0 + meta: ^1.9.1 rxdart: ^0.27.5 # marchdev.tk @@ -25,7 +25,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^1.0.0 + flutter_lints: ^3.0.1 flutter: uses-material-design: true