From 4e5c822666ffdc2ddd4242f03d437496e1da8e51 Mon Sep 17 00:00:00 2001 From: fzyzcjy <5236035+fzyzcjy@users.noreply.github.com> Date: Fri, 13 May 2022 09:08:52 +0800 Subject: [PATCH 1/6] Update chart_container.dart --- charts_flutter/lib/src/chart_container.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/charts_flutter/lib/src/chart_container.dart b/charts_flutter/lib/src/chart_container.dart index b10f5333a..45f970e43 100644 --- a/charts_flutter/lib/src/chart_container.dart +++ b/charts_flutter/lib/src/chart_container.dart @@ -202,11 +202,11 @@ class ChartContainerRenderObject extends RenderCustomPaint // Sometimes chart behaviors try to draw the chart outside of a Flutter draw // cycle. Schedule a frame manually to handle these cases. - if (!SchedulerBinding.instance!.hasScheduledFrame) { - SchedulerBinding.instance!.scheduleFrame(); + if (!SchedulerBinding.instance.hasScheduledFrame) { + SchedulerBinding.instance.scheduleFrame(); } - SchedulerBinding.instance!.addPostFrameCallback(startAnimationController); + SchedulerBinding.instance.addPostFrameCallback(startAnimationController); } /// Request Flutter to rebuild the widget/container of chart. @@ -229,7 +229,7 @@ class ChartContainerRenderObject extends RenderCustomPaint // This is needed to request rebuild after the legend has been added in the // post process phase of the chart, which happens during the chart widget's // build cycle. - SchedulerBinding.instance!.addPostFrameCallback(doRebuild); + SchedulerBinding.instance.addPostFrameCallback(doRebuild); } /// When Flutter's markNeedsLayout is called, layout and paint are both From a3f7c2fc42ed4afca870289017855615dc7d3594 Mon Sep 17 00:00:00 2001 From: fzyzcjy <5236035+fzyzcjy@users.noreply.github.com> Date: Fri, 13 May 2022 17:53:11 +0800 Subject: [PATCH 2/6] Update slider.dart --- charts_flutter/example/lib/behaviors/slider.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts_flutter/example/lib/behaviors/slider.dart b/charts_flutter/example/lib/behaviors/slider.dart index df45c6b04..6b7541011 100644 --- a/charts_flutter/example/lib/behaviors/slider.dart +++ b/charts_flutter/example/lib/behaviors/slider.dart @@ -119,7 +119,7 @@ class _SliderCallbackState extends State { }); } - SchedulerBinding.instance!.addPostFrameCallback(rebuild); + SchedulerBinding.instance.addPostFrameCallback(rebuild); } @override From b177e3a53f7b7c4fa70f875e74d746b24e741ac5 Mon Sep 17 00:00:00 2001 From: fzyzcjy <5236035+fzyzcjy@users.noreply.github.com> Date: Sat, 14 May 2022 07:05:53 +0800 Subject: [PATCH 3/6] Update pubspec.yaml --- charts_flutter/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts_flutter/pubspec.yaml b/charts_flutter/pubspec.yaml index f4987a364..0c7d675fd 100644 --- a/charts_flutter/pubspec.yaml +++ b/charts_flutter/pubspec.yaml @@ -5,7 +5,7 @@ homepage: https://github.com/google/charts environment: sdk: '>=2.12.0 <3.0.0' - flutter: '>=2.5.0' + flutter: '>=3.0.0' dependencies: # Pointing this to a local path allows for pointing to the latest code From a32f235af607589b9a03142cebef4f2e55742835 Mon Sep 17 00:00:00 2001 From: fzyzcjy <5236035+fzyzcjy@users.noreply.github.com> Date: Mon, 6 Jun 2022 17:33:13 +0800 Subject: [PATCH 4/6] Update pubspec.yaml --- charts_flutter/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts_flutter/pubspec.yaml b/charts_flutter/pubspec.yaml index 0c7d675fd..f4987a364 100644 --- a/charts_flutter/pubspec.yaml +++ b/charts_flutter/pubspec.yaml @@ -5,7 +5,7 @@ homepage: https://github.com/google/charts environment: sdk: '>=2.12.0 <3.0.0' - flutter: '>=3.0.0' + flutter: '>=2.5.0' dependencies: # Pointing this to a local path allows for pointing to the latest code From 9bde9b5972437cfeefa366b1697da443ba1ab86c Mon Sep 17 00:00:00 2001 From: fzyzcjy <5236035+fzyzcjy@users.noreply.github.com> Date: Mon, 6 Jun 2022 17:34:27 +0800 Subject: [PATCH 5/6] Update chart_container.dart --- charts_flutter/lib/src/chart_container.dart | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/charts_flutter/lib/src/chart_container.dart b/charts_flutter/lib/src/chart_container.dart index 45f970e43..94f74f07b 100644 --- a/charts_flutter/lib/src/chart_container.dart +++ b/charts_flutter/lib/src/chart_container.dart @@ -202,11 +202,11 @@ class ChartContainerRenderObject extends RenderCustomPaint // Sometimes chart behaviors try to draw the chart outside of a Flutter draw // cycle. Schedule a frame manually to handle these cases. - if (!SchedulerBinding.instance.hasScheduledFrame) { - SchedulerBinding.instance.scheduleFrame(); + if (!_ambiguate(SchedulerBinding.instance)!.hasScheduledFrame) { + _ambiguate(SchedulerBinding.instance)!.scheduleFrame(); } - SchedulerBinding.instance.addPostFrameCallback(startAnimationController); + _ambiguate(SchedulerBinding.instance)!.addPostFrameCallback(startAnimationController); } /// Request Flutter to rebuild the widget/container of chart. @@ -229,7 +229,7 @@ class ChartContainerRenderObject extends RenderCustomPaint // This is needed to request rebuild after the legend has been added in the // post process phase of the chart, which happens during the chart widget's // build cycle. - SchedulerBinding.instance.addPostFrameCallback(doRebuild); + _ambiguate(SchedulerBinding.instance)!.addPostFrameCallback(doRebuild); } /// When Flutter's markNeedsLayout is called, layout and paint are both @@ -377,3 +377,11 @@ class ChartContainerCustomPaint extends CustomPainter { return nodes; } } + +/// This allows a value of type T or T? +/// to be treated as a value of type T?. +/// +/// We use this so that APIs that have become +/// non-nullable can still be used with `!` and `?` +/// to support older versions of the API as well. +T? _ambiguate(T? value) => value; From d8ef37a3f6bcb38e21af7b307ab2133b294cdff4 Mon Sep 17 00:00:00 2001 From: fzyzcjy <5236035+fzyzcjy@users.noreply.github.com> Date: Mon, 6 Jun 2022 17:34:58 +0800 Subject: [PATCH 6/6] Update slider.dart --- charts_flutter/example/lib/behaviors/slider.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/charts_flutter/example/lib/behaviors/slider.dart b/charts_flutter/example/lib/behaviors/slider.dart index 6b7541011..79b1cc106 100644 --- a/charts_flutter/example/lib/behaviors/slider.dart +++ b/charts_flutter/example/lib/behaviors/slider.dart @@ -119,7 +119,7 @@ class _SliderCallbackState extends State { }); } - SchedulerBinding.instance.addPostFrameCallback(rebuild); + _ambiguate(SchedulerBinding.instance)!.addPostFrameCallback(rebuild); } @override @@ -194,3 +194,11 @@ class LinearSales { LinearSales(this.year, this.sales); } + +/// This allows a value of type T or T? +/// to be treated as a value of type T?. +/// +/// We use this so that APIs that have become +/// non-nullable can still be used with `!` and `?` +/// to support older versions of the API as well. +T? _ambiguate(T? value) => value;