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] 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;